Replace runTestCase with assert helpers [test/language/function-code]

This commit is contained in:
André Bargull 2015-08-13 17:34:40 +02:00
parent 73d5292b77
commit 789224fbaa
41 changed files with 95 additions and 264 deletions

View File

@ -7,12 +7,9 @@ description: >
Strict Mode - checking 'this' (non-strict function passed as arg
to String.prototype.replace from strict context)
flags: [noStrict]
includes:
- runTestCase.js
- fnGlobalObject.js
includes: [fnGlobalObject.js]
---*/
function testcase() {
var x = 3;
function f() {
@ -20,6 +17,5 @@ function f() {
return "a";
}
return (function() {"use strict"; return "ab".replace("b", f)==="aa";}()) && (x===fnGlobalObject());
}
runTestCase(testcase);
assert.sameValue(function() {"use strict"; return "ab".replace("b", f);}(), "aa");
assert.sameValue(x, fnGlobalObject(), 'x');

View File

@ -6,18 +6,15 @@ es5id: 10.4.3-1-102-s
description: >
Strict Mode - checking 'this' (strict anonymous function passed as
arg to String.prototype.replace)
includes: [runTestCase.js]
---*/
function testcase() {
var x = 3;
return ("ab".replace("b", (function () {
assert.sameValue("ab".replace("b", (function () {
"use strict";
return function () {
x = this;
return "a";
}
})())==="aa") && (x===undefined);
}
runTestCase(testcase);
})()), "aa");
assert.sameValue(x, undefined, 'x');

View File

@ -6,14 +6,9 @@ es5id: 10.4.3-1-103
description: >
Non strict mode should ToObject thisArg if not an object.
Abstract equality operator should succeed.
includes: [runTestCase.js]
---*/
function testcase(){
Object.defineProperty(Object.prototype, "x", { get: function () { return this; } });
if((5).x == 0) return false;
if(!((5).x == 5)) return false;
return true;
}
runTestCase(testcase);
assert.sameValue((5).x == 0, false, '(5).x == 0');
assert((5).x == 5, '(5).x == 5');

View File

@ -7,13 +7,8 @@ description: >
Strict mode should not ToObject thisArg if not an object. Strict
equality operator should succeed.
flags: [onlyStrict]
includes: [runTestCase.js]
---*/
function testcase(){
Object.defineProperty(Object.prototype, "x", { get: function () { return this; } });
if(!((5).x === 5)) return false;
return true;
}
runTestCase(testcase);
assert((5).x === 5, '(5).x === 5');

View File

@ -10,14 +10,9 @@ description: >
Non strict mode should ToObject thisArg if not an object. Return
type should be object and strict equality should fail.
flags: [noStrict]
includes: [runTestCase.js]
---*/
function testcase(){
Object.defineProperty(Object.prototype, "x", { get: function () { return this; } });
if((5).x === 5) return false;
if(!(typeof (5).x === "object")) return false;
return true;
}
runTestCase(testcase);
assert.sameValue((5).x === 5, false, '(5).x === 5');
assert.sameValue(typeof (5).x, "object", 'typeof (5).x');

View File

@ -10,13 +10,8 @@ description: >
Strict mode should not ToObject thisArg if not an object. Return
type should be 'number'.
flags: [onlyStrict]
includes: [runTestCase.js]
---*/
function testcase(){
Object.defineProperty(Object.prototype, "x", { get: function () { return this; } });
if(!(typeof (5).x === "number")) return false;
return true;
}
runTestCase(testcase);
assert.sameValue(typeof (5).x, "number", 'typeof (5).x');

View File

@ -7,12 +7,8 @@ description: >
Strict Mode - checking 'this' (Anonymous FunctionExpression
defined within strict mode)
flags: [onlyStrict]
includes: [runTestCase.js]
---*/
function testcase() {
return (function () {
assert.sameValue((function () {
return typeof this;
})() === "undefined";
}
runTestCase(testcase);
})(), "undefined");

View File

@ -7,13 +7,9 @@ description: >
Strict Mode - checking 'this' (Anonymous FunctionExpression
includes strict directive prologue)
flags: [noStrict]
includes: [runTestCase.js]
---*/
function testcase() {
return (function () {
assert.sameValue((function () {
"use strict";
return typeof this;
})() === "undefined";
}
runTestCase(testcase);
})(), "undefined");

View File

@ -5,12 +5,11 @@
es5id: 10.4.3-1-17-s
description: Strict Mode - checking 'this' (eval used within strict mode)
flags: [onlyStrict]
includes:
- runTestCase.js
- fnGlobalObject.js
includes: [fnGlobalObject.js]
---*/
function testcase() {
return (eval("typeof this") === "undefined") && (eval("this") !== fnGlobalObject());
assert.sameValue(eval("typeof this"), "undefined", 'eval("typeof this")');
assert.notSameValue(eval("this"), fnGlobalObject(), 'eval("this")');
}
runTestCase(testcase);
testcase();

View File

@ -7,13 +7,11 @@ description: >
Strict Mode - checking 'this' (indirect eval used within strict
mode)
flags: [onlyStrict]
includes:
- runTestCase.js
- fnGlobalObject.js
includes: [fnGlobalObject.js]
---*/
function testcase() {
var my_eval = eval;
return my_eval("this") === fnGlobalObject();
assert.sameValue(my_eval("this"), fnGlobalObject(), 'my_eval("this")');
}
runTestCase(testcase);
testcase();

View File

@ -7,13 +7,11 @@ description: >
Strict Mode - checking 'this' (indirect eval includes strict
directive prologue)
flags: [noStrict]
includes:
- runTestCase.js
- fnGlobalObject.js
includes: [fnGlobalObject.js]
---*/
function testcase() {
var my_eval = eval;
return my_eval("\"use strict\";\nthis") === fnGlobalObject();
assert.sameValue(my_eval("\"use strict\";\nthis"), fnGlobalObject());
}
runTestCase(testcase);
testcase();

View File

@ -7,15 +7,12 @@ description: >
Strict Mode - checking 'this' (FunctionDeclaration defined within
an Anonymous FunctionExpression inside strict mode)
flags: [onlyStrict]
includes: [runTestCase.js]
---*/
function testcase() {
return (function () {
(function () {
function f() {
return typeof this;
}
return (f()==="undefined") && ((typeof this)==="undefined");
assert.sameValue(f(), "undefined", 'f()');
assert.sameValue(typeof this, "undefined", 'typeof this');
})();
}
runTestCase(testcase);

View File

@ -7,15 +7,12 @@ description: >
Strict Mode - checking 'this' (FunctionExpression defined within
an Anonymous FunctionExpression inside strict mode)
flags: [onlyStrict]
includes: [runTestCase.js]
---*/
function testcase() {
return (function () {
(function () {
var f = function () {
return typeof this;
}
return (f()==="undefined") && ((typeof this)==="undefined");
assert.sameValue(f(), "undefined", 'f()');
assert.sameValue(typeof this, "undefined", 'typeof this');
})();
}
runTestCase(testcase);

View File

@ -7,14 +7,11 @@ description: >
Strict Mode - checking 'this' (Anonymous FunctionExpression
defined within an Anonymous FunctionExpression inside strict mode)
flags: [onlyStrict]
includes: [runTestCase.js]
---*/
function testcase() {
return (function () {
return ((function () {
(function () {
assert.sameValue((function () {
return typeof this;
})()==="undefined") && ((typeof this)==="undefined");
})(), "undefined");
assert.sameValue(typeof this, "undefined", 'typeof this');
})();
}
runTestCase(testcase);

View File

@ -7,16 +7,13 @@ description: >
Strict Mode - checking 'this' (FunctionDeclaration defined within
an Anonymous FunctionExpression with a strict directive prologue)
flags: [noStrict]
includes: [runTestCase.js]
---*/
function testcase() {
return (function () {
(function () {
"use strict";
function f() {
return typeof this;
}
return (f()==="undefined") && ((typeof this)==="undefined");
assert.sameValue(f(), "undefined", 'f()');
assert.sameValue(typeof this, "undefined", 'typeof this');
})();
}
runTestCase(testcase);

View File

@ -7,16 +7,13 @@ description: >
Strict Mode - checking 'this' (FunctionExpression defined within
an Anonymous FunctionExpression with a strict directive prologue)
flags: [noStrict]
includes: [runTestCase.js]
---*/
function testcase() {
return (function () {
(function () {
"use strict";
var f = function () {
return typeof this;
}
return (f()==="undefined") && ((typeof this)==="undefined");
assert.sameValue(f(), "undefined", 'f()');
assert.sameValue(typeof this, "undefined", 'typeof this');
})();
}
runTestCase(testcase);

View File

@ -8,15 +8,12 @@ description: >
defined within an Anonymous FunctionExpression with a strict
directive prologue)
flags: [noStrict]
includes: [runTestCase.js]
---*/
function testcase() {
return (function () {
(function () {
"use strict";
return ((function () {
assert.sameValue((function () {
return typeof this;
})()==="undefined") && ((typeof this)==="undefined");
})(), "undefined");
assert.sameValue(typeof this, "undefined", 'typeof this');
})();
}
runTestCase(testcase);

View File

@ -7,18 +7,14 @@ description: >
Strict Mode - checking 'this' (FunctionDeclaration with a strict
directive prologue defined within an Anonymous FunctionExpression)
flags: [noStrict]
includes:
- runTestCase.js
- fnGlobalObject.js
includes: [fnGlobalObject.js]
---*/
function testcase() {
return (function () {
(function () {
function f() {
"use strict";
return typeof this;
}
return (f()==="undefined") && (this===fnGlobalObject());
assert.sameValue(f(), "undefined", 'f()');
assert.sameValue(this, fnGlobalObject(), 'this');
})();
}
runTestCase(testcase);

View File

@ -7,18 +7,14 @@ description: >
Strict Mode - checking 'this' (FunctionExpression with a strict
directive prologue defined within an Anonymous FunctionExpression)
flags: [noStrict]
includes:
- runTestCase.js
- fnGlobalObject.js
includes: [fnGlobalObject.js]
---*/
function testcase() {
return (function () {
(function () {
var f = function () {
"use strict";
return typeof this;
}
return (f()==="undefined") && (this===fnGlobalObject());
assert.sameValue(f(), "undefined", 'f()');
assert.sameValue(this, fnGlobalObject(), 'this');
})();
}
runTestCase(testcase);

View File

@ -8,17 +8,13 @@ description: >
strict directive prologue defined within an Anonymous
FunctionExpression)
flags: [noStrict]
includes:
- runTestCase.js
- fnGlobalObject.js
includes: [fnGlobalObject.js]
---*/
function testcase() {
return (function () {
return ((function () {
(function () {
assert.sameValue((function () {
"use strict";
return typeof this;
})()==="undefined") && (this===fnGlobalObject());
})(), "undefined");
assert.sameValue(this, fnGlobalObject(), 'this');
})();
}
runTestCase(testcase);

View File

@ -5,11 +5,7 @@
es5id: 10.4.3-1-63-s
description: >
checking 'this' (strict function declaration called by non-strict eval)
includes: [runTestCase.js]
---*/
function testcase() {
function f() { "use strict"; return this===undefined;};
return eval("f();");
}
runTestCase(testcase);
assert(eval("f();"));

View File

@ -6,13 +6,8 @@ es5id: 10.4.3-1-64-s
description: >
checking 'this' (strict function declaration called by non-strict Function
constructor)
includes:
- runTestCase.js
- fnGlobalObject.js
includes: [fnGlobalObject.js]
---*/
function testcase() {
fnGlobalObject().f = function() { "use strict"; return this===undefined;};
return Function("return f();")();
}
runTestCase(testcase);
assert(Function("return f();")());

View File

@ -6,13 +6,8 @@ es5id: 10.4.3-1-65-s
description: >
checking 'this' (strict function declaration called by non-strict new'ed
Function constructor)
includes:
- runTestCase.js
- fnGlobalObject.js
includes: [fnGlobalObject.js]
---*/
function testcase() {
fnGlobalObject().f = function() { "use strict"; return this===undefined;};
return (new Function("return f();"))();
}
runTestCase(testcase);
assert((new Function("return f();"))());

View File

@ -7,11 +7,7 @@ description: >
Strict Mode - checking 'this' (non-strict function declaration
called by strict eval)
flags: [noStrict]
includes: [runTestCase.js]
---*/
function testcase() {
function f() { return this!==undefined;};
return (function () {"use strict"; return eval("f();");})();
}
runTestCase(testcase);
assert((function () {"use strict"; return eval("f();");})());

View File

@ -7,13 +7,8 @@ description: >
Strict Mode - checking 'this' (non-strict function declaration
called by strict Function constructor)
flags: [noStrict]
includes:
- runTestCase.js
- fnGlobalObject.js
includes: [fnGlobalObject.js]
---*/
function testcase() {
fnGlobalObject().f = function() {return this!==undefined;};
return (function () {return Function("\"use strict\";return f();")();})();
}
runTestCase(testcase);
assert((function () {return Function("\"use strict\";return f();")();})());

View File

@ -7,13 +7,8 @@ description: >
Strict Mode - checking 'this' (non-strict function declaration
called by strict new'ed Function constructor)
flags: [noStrict]
includes:
- runTestCase.js
- fnGlobalObject.js
includes: [fnGlobalObject.js]
---*/
function testcase() {
fnGlobalObject().f = function() { return this!==undefined;};
return (function () {return new Function("\"use strict\";return f();")();})();
}
runTestCase(testcase);
assert((function () {return new Function("\"use strict\";return f();")();})());

View File

@ -7,11 +7,7 @@ description: >
Strict Mode - checking 'this' (non-strict function declaration
called by strict Function.prototype.apply())
flags: [noStrict]
includes: [runTestCase.js]
---*/
function testcase() {
function f() { return this!==undefined;};
return (function () {"use strict"; return f.apply();})();
}
runTestCase(testcase);
assert((function () {"use strict"; return f.apply();})());

View File

@ -7,13 +7,8 @@ description: >
Strict Mode - checking 'this' (non-strict function declaration
called by strict Function.prototype.apply(null))
flags: [noStrict]
includes:
- runTestCase.js
- fnGlobalObject.js
includes: [fnGlobalObject.js]
---*/
function testcase() {
function f() { return this===fnGlobalObject();};
return (function () {"use strict"; return f.apply(null);})();
}
runTestCase(testcase);
assert((function () {"use strict"; return f.apply(null);})());

View File

@ -7,13 +7,8 @@ description: >
Strict Mode - checking 'this' (non-strict function declaration
called by strict Function.prototype.apply(undefined))
flags: [noStrict]
includes:
- runTestCase.js
- fnGlobalObject.js
includes: [fnGlobalObject.js]
---*/
function testcase() {
function f() { return this===fnGlobalObject()};
return (function () {"use strict"; return f.apply(undefined);})();
}
runTestCase(testcase);
assert((function () {"use strict"; return f.apply(undefined);})());

View File

@ -7,12 +7,8 @@ description: >
Strict Mode - checking 'this' (non-strict function declaration
called by strict Function.prototype.apply(someObject))
flags: [noStrict]
includes: [runTestCase.js]
---*/
function testcase() {
var o = {};
function f() { return this===o;};
return (function () {"use strict"; return f.apply(o);})();
}
runTestCase(testcase);
assert((function () {"use strict"; return f.apply(o);})());

View File

@ -7,13 +7,8 @@ description: >
Strict Mode - checking 'this' (non-strict function declaration
called by strict Function.prototype.apply(globalObject))
flags: [noStrict]
includes:
- runTestCase.js
- fnGlobalObject.js
includes: [fnGlobalObject.js]
---*/
function testcase() {
function f() { return this;};
return (function () {"use strict"; return f.apply(fnGlobalObject()); })() === fnGlobalObject();
}
runTestCase(testcase);
assert.sameValue((function () {"use strict"; return f.apply(fnGlobalObject()); })(), fnGlobalObject());

View File

@ -7,13 +7,8 @@ description: >
Strict Mode - checking 'this' (non-strict function declaration
called by strict Function.prototype.call())
flags: [noStrict]
includes:
- runTestCase.js
- fnGlobalObject.js
includes: [fnGlobalObject.js]
---*/
function testcase() {
function f() { return this===fnGlobalObject();};
return (function () {"use strict"; return f.call(); })();
}
runTestCase(testcase);
assert((function () {"use strict"; return f.call(); })());

View File

@ -7,13 +7,8 @@ description: >
Strict Mode - checking 'this' (non-strict function declaration
called by strict Function.prototype.call(null))
flags: [noStrict]
includes:
- runTestCase.js
- fnGlobalObject.js
includes: [fnGlobalObject.js]
---*/
function testcase() {
function f() { return this===fnGlobalObject();};
return (function () {"use strict"; return f.call(null); })();
}
runTestCase(testcase);
assert((function () {"use strict"; return f.call(null); })());

View File

@ -7,13 +7,8 @@ description: >
Strict Mode - checking 'this' (non-strict function declaration
called by strict Function.prototype.call(undefined))
flags: [noStrict]
includes:
- runTestCase.js
- fnGlobalObject.js
includes: [fnGlobalObject.js]
---*/
function testcase() {
function f() { return this===fnGlobalObject();};
return (function () {"use strict"; return f.call(undefined);})();
}
runTestCase(testcase);
assert((function () {"use strict"; return f.call(undefined);})());

View File

@ -7,12 +7,8 @@ description: >
Strict Mode - checking 'this' (non-strict function declaration
called by strict Function.prototype.call(someObject))
flags: [noStrict]
includes: [runTestCase.js]
---*/
function testcase() {
var o = {};
function f() { return this===o;};
return (function () {"use strict"; return f.call(o); })();
}
runTestCase(testcase);
assert((function () {"use strict"; return f.call(o); })());

View File

@ -7,13 +7,8 @@ description: >
Strict Mode - checking 'this' (non-strict function declaration
called by strict Function.prototype.call(globalObject))
flags: [noStrict]
includes:
- runTestCase.js
- fnGlobalObject.js
includes: [fnGlobalObject.js]
---*/
function testcase() {
function f() { return this===fnGlobalObject();};
return (function () {"use strict"; return f.call(fnGlobalObject());})();
}
runTestCase(testcase);
assert((function () {"use strict"; return f.call(fnGlobalObject());})());

View File

@ -7,13 +7,8 @@ description: >
Strict Mode - checking 'this' (non-strict function declaration
called by strict Function.prototype.bind()())
flags: [noStrict]
includes:
- runTestCase.js
- fnGlobalObject.js
includes: [fnGlobalObject.js]
---*/
function testcase() {
function f() { return this===fnGlobalObject();};
return (function () {"use strict"; return f.bind()(); })();
}
runTestCase(testcase);
assert((function () {"use strict"; return f.bind()(); })());

View File

@ -7,13 +7,8 @@ description: >
Strict Mode - checking 'this' (non-strict function declaration
called by strict Function.prototype.bind(null)())
flags: [noStrict]
includes:
- runTestCase.js
- fnGlobalObject.js
includes: [fnGlobalObject.js]
---*/
function testcase() {
function f() { return this===fnGlobalObject();};
return (function () {"use strict"; return f.bind(null)(); })();
}
runTestCase(testcase);
assert((function () {"use strict"; return f.bind(null)(); })());

View File

@ -7,13 +7,8 @@ description: >
Strict Mode - checking 'this' (non-strict function declaration
called by strict Function.prototype.bind(undefined)())
flags: [noStrict]
includes:
- runTestCase.js
- fnGlobalObject.js
includes: [fnGlobalObject.js]
---*/
function testcase() {
function f() { return this===fnGlobalObject();};
return (function () {"use strict"; return f.bind(undefined)();})();
}
runTestCase(testcase);
assert((function () {"use strict"; return f.bind(undefined)();})());

View File

@ -7,12 +7,8 @@ description: >
Strict Mode - checking 'this' (non-strict function declaration
called by strict Function.prototype.bind(someObject)())
flags: [noStrict]
includes: [runTestCase.js]
---*/
function testcase() {
var o = {};
function f() { return this===o;};
return (function () {"use strict"; return f.bind(o)();})();
}
runTestCase(testcase);
assert((function () {"use strict"; return f.bind(o)();})());

View File

@ -7,13 +7,8 @@ description: >
Strict Mode - checking 'this' (non-strict function declaration
called by strict Function.prototype.bind(globalObject)())
flags: [noStrict]
includes:
- runTestCase.js
- fnGlobalObject.js
includes: [fnGlobalObject.js]
---*/
function testcase() {
function f() { return this===fnGlobalObject();};
return (function () {"use strict"; return f.bind(fnGlobalObject())();})();
}
runTestCase(testcase);
assert((function () {"use strict"; return f.bind(fnGlobalObject())();})());