Change 'assert' handle to pass only upon exactly 1 argument is received, and the argument is boolean true; update internal test suite correspondingly.

JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan r.ayrapetyan@samsung.com
This commit is contained in:
Ruben Ayrapetyan 2015-07-30 15:13:16 +03:00
parent 5d385b1144
commit c715a7cd1d
44 changed files with 138 additions and 137 deletions

View File

@ -113,7 +113,7 @@ read_sources (const char *script_file_names[],
/**
* Provide the 'assert' implementation for the engine.
*
* @return true - if the argument was not a boolean value or it was boolean true.
* @return true - if only one argument was passed and the argument is a boolean true.
*/
static bool
assert_handler (const jerry_api_object_t *function_obj_p __attr_unused___, /** < function object */
@ -122,18 +122,19 @@ assert_handler (const jerry_api_object_t *function_obj_p __attr_unused___, /** <
const jerry_api_value_t args_p[], /** < function arguments */
const jerry_api_length_t args_cnt) /** < number of function arguments */
{
if (args_cnt > 0
if (args_cnt == 1
&& args_p[0].type == JERRY_API_DATA_TYPE_BOOLEAN
&& args_p[0].v_bool != true)
&& args_p[0].v_bool == true)
{
return true;
}
else
{
JERRY_ERROR_MSG ("Script assertion failed\n");
exit (JERRY_STANDALONE_EXIT_CODE_FAIL);
}
return true;
} /* assert_handler */
int
main (int argc,
char **argv)

View File

@ -1,4 +1,4 @@
// Copyright 2014 Samsung Electronics Co., Ltd.
// Copyright 2014-2015 Samsung Electronics Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -12,12 +12,12 @@
// See the License for the specific language governing permissions and
// limitations under the License.
assert(test());
assert (test ());
function test(arg)
function test (arg)
{
if (typeof (arg) === "undefined")
return 1;
return true;
else
return 0;
return false;
}

View File

@ -1,4 +1,4 @@
// Copyright 2014 Samsung Electronics Co., Ltd.
// Copyright 2014-2015 Samsung Electronics Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -12,12 +12,12 @@
// See the License for the specific language governing permissions and
// limitations under the License.
assert(test());
assert (test ());
function test(arg)
function test (arg)
{
if (typeof (arg) === "undefined")
return 1;
return true;
else
return 0;
return false;
}

View File

@ -1,4 +1,4 @@
// Copyright 2014 Samsung Electronics Co., Ltd.
// Copyright 2014-2015 Samsung Electronics Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -13,5 +13,5 @@
// limitations under the License.
var a = NaN;
var b = new Object();
assert((!a && b))
var b = new Object ();
assert ((!a && b) === b);

View File

@ -1,4 +1,4 @@
// Copyright 2014 Samsung Electronics Co., Ltd.
// Copyright 2014-2015 Samsung Electronics Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -15,4 +15,4 @@
var a = 0xffffffff;
var _a = a;
var b = 4;
assert(a >>= b === _a >> b)
assert ((a >>= b) === (_a >> b));

View File

@ -1,4 +1,4 @@
// Copyright 2014 Samsung Electronics Co., Ltd.
// Copyright 2014-2015 Samsung Electronics Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -15,4 +15,4 @@
var a = 0xffffffff;
var _a = a;
var b = 4;
assert(a <<= b === _a << b)
assert ((a <<= b) === (_a << b));

View File

@ -1,4 +1,4 @@
// Copyright 2014 Samsung Electronics Co., Ltd.
// Copyright 2014-2015 Samsung Electronics Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -15,4 +15,4 @@
var a = 0xffffffff;
var _a = a;
var b = 4;
assert(a >>>= b === _a >>> b)
assert ((a >>>= b) === (_a >>> b));

View File

@ -1,4 +1,4 @@
// Copyright 2014 Samsung Electronics Co., Ltd.
// Copyright 2014-2015 Samsung Electronics Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -12,12 +12,12 @@
// See the License for the specific language governing permissions and
// limitations under the License.
function test()
function test ()
{
{
return 1;
return true;
}
return 0;
return false;
}
assert(test());
assert (test ());

View File

@ -1,4 +1,4 @@
// Copyright 2014 Samsung Electronics Co., Ltd.
// Copyright 2014-2015 Samsung Electronics Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -29,4 +29,4 @@ switch ("key") {
break;
}
assert(matchesCount === 1 ? 1 : 0);
assert (matchesCount === 1);

View File

@ -1,4 +1,4 @@
// Copyright 2014 Samsung Electronics Co., Ltd.
// Copyright 2014-2015 Samsung Electronics Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -25,4 +25,4 @@ switch ("key") {
++counter;
}
assert(counter == 4 ? 1 : 0);
assert (counter == 4);

View File

@ -1,4 +1,4 @@
// Copyright 2014 Samsung Electronics Co., Ltd.
// Copyright 2014-2015 Samsung Electronics Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -12,16 +12,16 @@
// See the License for the specific language governing permissions and
// limitations under the License.
function test()
function test ()
{
try {
if (true) {
throw "error";
}
} catch (e) {
return 1;
return true;
}
return 0;
return false;
}
assert(test());
assert (test ());

View File

@ -1,4 +1,4 @@
// Copyright 2014 Samsung Electronics Co., Ltd.
// Copyright 2014-2015 Samsung Electronics Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -12,16 +12,16 @@
// See the License for the specific language governing permissions and
// limitations under the License.
function test()
function test ()
{
try {
while (true) {
throw "error";
}
} catch (e) {
return 0;
return true;
}
return 1;
return false;
}
assert(test);
assert (test ());

View File

@ -1,4 +1,4 @@
// Copyright 2014 Samsung Electronics Co., Ltd.
// Copyright 2014-2015 Samsung Electronics Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -12,27 +12,27 @@
// See the License for the specific language governing permissions and
// limitations under the License.
function d() {
function d () {
throw "exception";
}
function c() {
d();
function c () {
d ();
}
function b() {
c();
function b () {
c ();
}
function a() {
b();
function a () {
b ();
}
function test()
function test ()
{
try {
a();
a ();
} catch (e) {
return 1;
return true;
}
return 0;
return false;
}
assert(test());
assert (test ());

View File

@ -1,4 +1,4 @@
// Copyright 2014 Samsung Electronics Co., Ltd.
// Copyright 2014-2015 Samsung Electronics Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -12,15 +12,15 @@
// See the License for the specific language governing permissions and
// limitations under the License.
function test()
function test ()
{
try {
var x = 1;
} catch (e) {
return 0;
return false;
}
return 1;
return true;
}
assert(test());
assert (test ());

View File

@ -1,4 +1,4 @@
// Copyright 2014 Samsung Electronics Co., Ltd.
// Copyright 2014-2015 Samsung Electronics Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -12,15 +12,15 @@
// See the License for the specific language governing permissions and
// limitations under the License.
function test()
function test ()
{
try {
throw 1;
} catch (e) {
return e === 1 ? 0 : 1;
return (e === 1);
}
return 1;
return false;
}
assert (test);
assert (test ());

View File

@ -1,4 +1,4 @@
// Copyright 2014 Samsung Electronics Co., Ltd.
// Copyright 2014-2015 Samsung Electronics Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -12,17 +12,17 @@
// See the License for the specific language governing permissions and
// limitations under the License.
function test()
function test ()
{
try {
throw "error";
} catch (e) {
return 1;
return false;
} finally {
return 0;
return true;
}
return 1;
return false;
}
assert(test);
assert (test ());

View File

@ -1,4 +1,4 @@
// Copyright 2014 Samsung Electronics Co., Ltd.
// Copyright 2014-2015 Samsung Electronics Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -12,16 +12,16 @@
// See the License for the specific language governing permissions and
// limitations under the License.
function test()
function test ()
{
try {
throw "error";
} catch (e) {
return 1;
return true;
} finally {
}
return 0;
return false;
}
assert(test());
assert (test ());

View File

@ -1,4 +1,4 @@
// Copyright 2014 Samsung Electronics Co., Ltd.
// Copyright 2014-2015 Samsung Electronics Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -12,15 +12,15 @@
// See the License for the specific language governing permissions and
// limitations under the License.
function test()
function test ()
{
try {
var x = 1;
} finally {
return 1;
return true;
}
return 0;
return false;
}
assert(test());
assert (test ());

View File

@ -1,4 +1,4 @@
// Copyright 2014 Samsung Electronics Co., Ltd.
// Copyright 2014-2015 Samsung Electronics Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
function arguments(param) {
return 1;
function arguments (param) {
return true;
}
assert(arguments());
assert (arguments ());

View File

@ -1,4 +1,4 @@
// Copyright 2014 Samsung Electronics Co., Ltd.
// Copyright 2014-2015 Samsung Electronics Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -12,4 +12,4 @@
// See the License for the specific language governing permissions and
// limitations under the License.
assert(String() === String("") ? 1 : 0);
assert (String () === String (""));

View File

@ -1,4 +1,4 @@
// Copyright 2014 Samsung Electronics Co., Ltd.
// Copyright 2014-2015 Samsung Electronics Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -12,4 +12,4 @@
// See the License for the specific language governing permissions and
// limitations under the License.
assert(String(undefined) === "undefined" ? 1 : 0);
assert (String (undefined) === "undefined");

View File

@ -1,4 +1,4 @@
// Copyright 2014 Samsung Electronics Co., Ltd.
// Copyright 2014-2015 Samsung Electronics Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -12,4 +12,4 @@
// See the License for the specific language governing permissions and
// limitations under the License.
assert(String(null) === "null" ? 1 : 0);
assert (String (null) === "null");

View File

@ -1,4 +1,4 @@
// Copyright 2014 Samsung Electronics Co., Ltd.
// Copyright 2014-2015 Samsung Electronics Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -12,4 +12,4 @@
// See the License for the specific language governing permissions and
// limitations under the License.
assert(String(true) === "true" ? 1 : 0);
assert (String (true) === "true");

View File

@ -1,4 +1,4 @@
// Copyright 2014 Samsung Electronics Co., Ltd.
// Copyright 2014-2015 Samsung Electronics Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -12,4 +12,4 @@
// See the License for the specific language governing permissions and
// limitations under the License.
assert(String(false) === "false" ? 1 : 0);
assert (String (false) === "false");

View File

@ -1,4 +1,4 @@
// Copyright 2014 Samsung Electronics Co., Ltd.
// Copyright 2014-2015 Samsung Electronics Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -12,4 +12,4 @@
// See the License for the specific language governing permissions and
// limitations under the License.
assert(String(+0) === "0" ? 1 : 0);
assert (String (+0) === "0");

View File

@ -1,4 +1,4 @@
// Copyright 2014 Samsung Electronics Co., Ltd.
// Copyright 2014-2015 Samsung Electronics Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -12,4 +12,4 @@
// See the License for the specific language governing permissions and
// limitations under the License.
assert(String(-0) === "0" ? 1 : 0);
assert (String (-0) === "0");

View File

@ -1,4 +1,4 @@
// Copyright 2014 Samsung Electronics Co., Ltd.
// Copyright 2014-2015 Samsung Electronics Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -12,4 +12,4 @@
// See the License for the specific language governing permissions and
// limitations under the License.
assert(String(-1) === "-" + String(1) ? 1 : 0);
assert (String (-1) === "-" + String (1));

View File

@ -1,4 +1,4 @@
// Copyright 2014 Samsung Electronics Co., Ltd.
// Copyright 2014-2015 Samsung Electronics Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -12,4 +12,4 @@
// See the License for the specific language governing permissions and
// limitations under the License.
assert(String(Infinity) === "Infinity" ? 1 : 0);
assert (String (Infinity) === "Infinity");

View File

@ -1,4 +1,4 @@
// Copyright 2014 Samsung Electronics Co., Ltd.
// Copyright 2014-2015 Samsung Electronics Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -12,4 +12,4 @@
// See the License for the specific language governing permissions and
// limitations under the License.
assert(String(123000) === "123000" ? 1 : 0);
assert (String (123000) === "123000");

View File

@ -1,4 +1,4 @@
// Copyright 2014 Samsung Electronics Co., Ltd.
// Copyright 2014-2015 Samsung Electronics Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -12,4 +12,4 @@
// See the License for the specific language governing permissions and
// limitations under the License.
assert(String(10000000000000000000) === "10000000000000000000" ? 1 : 0);
assert (String (10000000000000000000) === "10000000000000000000");

View File

@ -1,4 +1,4 @@
// Copyright 2014 Samsung Electronics Co., Ltd.
// Copyright 2014-2015 Samsung Electronics Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -12,4 +12,4 @@
// See the License for the specific language governing permissions and
// limitations under the License.
assert(String(0.111111111111111) === "0.111111111111111" ? 1 : 0);
assert (String (0.111111111111111) === "0.111111111111111");

View File

@ -1,4 +1,4 @@
// Copyright 2014 Samsung Electronics Co., Ltd.
// Copyright 2014-2015 Samsung Electronics Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -12,4 +12,4 @@
// See the License for the specific language governing permissions and
// limitations under the License.
assert(String(0.00000111111111111111) === "0.00000111111111111111" ? 1 : 0);
assert (String (0.00000111111111111111) === "0.00000111111111111111");

View File

@ -1,4 +1,4 @@
// Copyright 2014 Samsung Electronics Co., Ltd.
// Copyright 2014-2015 Samsung Electronics Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -12,4 +12,4 @@
// See the License for the specific language governing permissions and
// limitations under the License.
assert(String(0.000000111111111111111) === "1.11111111111111e-7" ? 1 : 0);
assert (String (0.000000111111111111111) === "1.11111111111111e-7");

View File

@ -1,4 +1,4 @@
// Copyright 2014 Samsung Electronics Co., Ltd.
// Copyright 2014-2015 Samsung Electronics Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -12,6 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.
var s = new String("");
var s = new String ("");
s.x = 1;
assert((s.x === 1) ? 1 : 0);
assert (s.x === 1);

View File

@ -1,4 +1,4 @@
// Copyright 2014 Samsung Electronics Co., Ltd.
// Copyright 2014-2015 Samsung Electronics Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -12,4 +12,4 @@
// See the License for the specific language governing permissions and
// limitations under the License.
assert(String.fromCharCode() === "" ? 1 : 0);
assert (String.fromCharCode () === "");

View File

@ -1,4 +1,4 @@
// Copyright 2014 Samsung Electronics Co., Ltd.
// Copyright 2014-2015 Samsung Electronics Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -12,4 +12,4 @@
// See the License for the specific language governing permissions and
// limitations under the License.
assert(String.fromCharCode(65, 66, 67) === "ABC" ? 1 : 0);
assert (String.fromCharCode (65, 66, 67) === "ABC");

View File

@ -1,4 +1,4 @@
// Copyright 2014 Samsung Electronics Co., Ltd.
// Copyright 2014-2015 Samsung Electronics Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -12,4 +12,4 @@
// See the License for the specific language governing permissions and
// limitations under the License.
assert((String.prototype.constructor === String) ? 1 : 0);
assert (String.prototype.constructor === String);

View File

@ -1,4 +1,4 @@
// Copyright 2014 Samsung Electronics Co., Ltd.
// Copyright 2014-2015 Samsung Electronics Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -12,4 +12,4 @@
// See the License for the specific language governing permissions and
// limitations under the License.
assert((String("abc").toString() === "abc") ? 1 : 0);
assert (String ("abc").toString () === "abc");

View File

@ -1,4 +1,4 @@
// Copyright 2014 Samsung Electronics Co., Ltd.
// Copyright 2014-2015 Samsung Electronics Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -12,4 +12,4 @@
// See the License for the specific language governing permissions and
// limitations under the License.
assert(("abc".toString() === "abc") ? 1 : 0);
assert ("abc".toString () === "abc");

View File

@ -1,4 +1,4 @@
// Copyright 2014 Samsung Electronics Co., Ltd.
// Copyright 2014-2015 Samsung Electronics Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -12,4 +12,4 @@
// See the License for the specific language governing permissions and
// limitations under the License.
assert(String("abc").valueOf() === "abc" ? 1 : 0);
assert (String ("abc").valueOf () === "abc");

View File

@ -1,4 +1,4 @@
// Copyright 2014 Samsung Electronics Co., Ltd.
// Copyright 2014-2015 Samsung Electronics Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -12,4 +12,4 @@
// See the License for the specific language governing permissions and
// limitations under the License.
assert(String().concat.length === 1 ? 1 : 0);
assert (String ().concat.length === 1);

View File

@ -1,4 +1,4 @@
// Copyright 2014 Samsung Electronics Co., Ltd.
// Copyright 2014-2015 Samsung Electronics Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -12,6 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.
var b = new Boolean(true);
var b = new Boolean (true);
b.x = 1;
assert((b.x === 1) ? 1 : 0);
assert (b.x === 1);

View File

@ -116,7 +116,7 @@ var props = {
var obj3 = Object.create(obj, props);
assert (obj3.prop1 === 1);
assert (obj3.protoFunction());
assert (obj3.protoFunction() === 3);
try {
assert (obj3.hey === undefined);
obj3.hey();

View File

@ -18,7 +18,7 @@ assert ("hello".replace("", ":") === ":hello");
assert ("xabcxabcx".replace (/abc/g, "[$&][$`][$']") === "x[abc][x][xabcx]x[abc][xabcx][x]x");
assert ("abc".replace (/a(b)c|d()/, "[$1][$01][$2][$02][$99][$123][$012]") === "[b][b][][][][3][b2]");
assert ("abc".replace("abc", "$x$$5$0$00$" === "$x$5$0$00$"));
assert ("abc".replace("abc", "$x$$5$0$00$") === "$x$5$0$00$");
assert ("a true true story".replace(true) === "a undefined true story");
assert ("1234".replace(23, 32) === "1324");