mirror of
https://github.com/tc39/test262.git
synced 2025-07-22 05:24:38 +02:00
Transform legacy format to harness assertions: test/built-ins/E*/**/*.js
This commit is contained in:
parent
f1720c4a0c
commit
1286bb601e
@ -13,11 +13,11 @@ var proto = Error.prototype;
|
|||||||
//CHECK#1
|
//CHECK#1
|
||||||
verifyNotConfigurable(Error, "prototype");
|
verifyNotConfigurable(Error, "prototype");
|
||||||
try {
|
try {
|
||||||
if ((delete Error.prototype) !== false) {
|
assert.sameValue(delete Error.prototype, false);
|
||||||
throw new Test262Error('#1: Error.prototype has the attribute DontDelete');
|
|
||||||
}
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e instanceof Test262Error) throw e;
|
if (e instanceof Test262Error) {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
assert(e instanceof TypeError);
|
assert(e instanceof TypeError);
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
@ -30,3 +30,5 @@ if (Error.prototype !== proto) {
|
|||||||
}
|
}
|
||||||
//
|
//
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// TODO: Convert to verifyProperty() format.
|
||||||
|
@ -6,21 +6,13 @@ info: Error.prototype property has the attributes {DontEnum}
|
|||||||
es5id: 15.11.3.1_A2_T1
|
es5id: 15.11.3.1_A2_T1
|
||||||
description: Checking if enumerating the Error.prototype property fails
|
description: Checking if enumerating the Error.prototype property fails
|
||||||
---*/
|
---*/
|
||||||
|
assert(Error.hasOwnProperty('prototype'), 'Error.hasOwnProperty(\'prototype\') must return true');
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
assert(
|
||||||
//CHECK#0
|
!Error.propertyIsEnumerable('prototype'),
|
||||||
if (!(Error.hasOwnProperty('prototype'))) {
|
'The value of !Error.propertyIsEnumerable(\'prototype\') is expected to be true'
|
||||||
throw new Test262Error('#0: Error.hasOwnProperty(\'prototype\') return true. Actual: ' + Error.hasOwnProperty('prototype'));
|
);
|
||||||
}
|
|
||||||
//
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
// CHECK#1
|
|
||||||
if (Error.propertyIsEnumerable('prototype')) {
|
|
||||||
throw new Test262Error('#1: Error.propertyIsEnumerable(\'prototype\') return false. Actual: ' + Error.propertyIsEnumerable('prototype'));
|
|
||||||
}
|
|
||||||
//
|
//
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@ -30,11 +22,11 @@ if (Error.propertyIsEnumerable('prototype')) {
|
|||||||
var cout = 0;
|
var cout = 0;
|
||||||
|
|
||||||
for (var p in Error) {
|
for (var p in Error) {
|
||||||
if (p === "prototype") cout++;
|
if (p === "prototype") {
|
||||||
|
cout++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cout !== 0) {
|
assert.sameValue(cout, 0, 'The value of cout is expected to be 0');
|
||||||
throw new Test262Error('#2: cout === 0. Actual: ' + cout);
|
|
||||||
}
|
// TODO: Convert to verifyProperty() format.
|
||||||
//
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
@ -7,14 +7,7 @@ es5id: 15.11.3.1_A3_T1
|
|||||||
description: Checking if varying the Error.prototype property fails
|
description: Checking if varying the Error.prototype property fails
|
||||||
includes: [propertyHelper.js]
|
includes: [propertyHelper.js]
|
||||||
---*/
|
---*/
|
||||||
|
assert(Error.hasOwnProperty('prototype'));
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
//CHECK#1
|
|
||||||
if (!(Error.hasOwnProperty('prototype'))) {
|
|
||||||
throw new Test262Error('#1: Error.hasOwnProperty(\'prototype\') return true. Actual: ' + Error.hasOwnProperty('prototype'));
|
|
||||||
}
|
|
||||||
//
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
var __obj = Error.prototype;
|
var __obj = Error.prototype;
|
||||||
|
|
||||||
@ -22,21 +15,7 @@ verifyNotWritable(Error, "prototype", null, function() {
|
|||||||
return "shifted";
|
return "shifted";
|
||||||
});
|
});
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
assert.sameValue(Error.prototype, __obj);
|
||||||
//CHECK#2
|
|
||||||
if (Error.prototype !== __obj) {
|
// TODO: Convert to verifyProperty() format.
|
||||||
throw new Test262Error('#2: __obj = Error.prototype; Error.prototype = function(){return "shifted";}; Error.prototype === __obj. Actual: ' + Error.prototype);
|
|
||||||
}
|
|
||||||
//
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
//CHECK#3
|
|
||||||
try {
|
|
||||||
Error.prototype();
|
|
||||||
throw new Test262Error('#3: "Error.prototype()" lead to throwing exception');
|
|
||||||
} catch (e) {
|
|
||||||
if (e instanceof Test262Error) throw e;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
@ -6,11 +6,4 @@ info: The Error has property prototype
|
|||||||
es5id: 15.11.3.1_A4_T1
|
es5id: 15.11.3.1_A4_T1
|
||||||
description: Checking Error.hasOwnProperty('prototype')
|
description: Checking Error.hasOwnProperty('prototype')
|
||||||
---*/
|
---*/
|
||||||
|
assert(Error.hasOwnProperty('prototype'), 'Error.hasOwnProperty(\'prototype\') must return true');
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
//CHECK#1
|
|
||||||
if (!(Error.hasOwnProperty('prototype'))) {
|
|
||||||
throw new Test262Error('#1: Error.hasOwnProperty(\'prototype\') return true. Actual: ' + Error.hasOwnProperty('prototype'));
|
|
||||||
}
|
|
||||||
//
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
12
test/built-ins/Error/prototype/S15.11.4_A1.js
vendored
12
test/built-ins/Error/prototype/S15.11.4_A1.js
vendored
@ -8,11 +8,7 @@ info: |
|
|||||||
es5id: 15.11.4_A1
|
es5id: 15.11.4_A1
|
||||||
description: Get Error.prototype and compare with Object.prototype
|
description: Get Error.prototype and compare with Object.prototype
|
||||||
---*/
|
---*/
|
||||||
|
assert(
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
Object.prototype.isPrototypeOf(Error.prototype),
|
||||||
// CHECK#1
|
'Object.prototype.isPrototypeOf(Error.prototype) must return true'
|
||||||
if (!Object.prototype.isPrototypeOf(Error.prototype)) {
|
);
|
||||||
throw new Test262Error('#1: Object.prototype.isPrototypeOf(Error.prototype) return true. Actual: ' + Object.prototype.isPrototypeOf(Error.prototype));
|
|
||||||
}
|
|
||||||
//
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
@ -14,10 +14,4 @@ description: >
|
|||||||
Error.prototype.toString = Object.prototype.toString;
|
Error.prototype.toString = Object.prototype.toString;
|
||||||
var __tostr = Error.prototype.toString();
|
var __tostr = Error.prototype.toString();
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
assert.sameValue(__tostr, "[object Object]", 'The value of __tostr is expected to be "[object Object]"');
|
||||||
//CHECK#1
|
|
||||||
if (__tostr !== "[object Object]") {
|
|
||||||
throw new Test262Error('#1: Error.prototype.toString=Object.prototype.toString; __tostr = Error.prototype.toString(); __tostr === "[object Object]". Actual: ' + __tostr);
|
|
||||||
}
|
|
||||||
//
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
12
test/built-ins/Error/prototype/S15.11.4_A3.js
vendored
12
test/built-ins/Error/prototype/S15.11.4_A3.js
vendored
@ -7,13 +7,7 @@ es5id: 15.11.4_A3
|
|||||||
description: Checking if call of Error prototype as a function fails
|
description: Checking if call of Error prototype as a function fails
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
asserts.throws(TypeError, () => {
|
||||||
//CHECK#1
|
|
||||||
try {
|
|
||||||
Error.prototype();
|
Error.prototype();
|
||||||
throw new Test262Error('#1: "Error.prototype()" lead to throwing exception');
|
throw new Test262Error();
|
||||||
} catch (e) {
|
});
|
||||||
if (e instanceof Test262Error) throw e;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
14
test/built-ins/Error/prototype/S15.11.4_A4.js
vendored
14
test/built-ins/Error/prototype/S15.11.4_A4.js
vendored
@ -7,13 +7,7 @@ es5id: 15.11.4_A4
|
|||||||
description: Checking if creating "new Error.prototype" fails
|
description: Checking if creating "new Error.prototype" fails
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
asserts.throws(TypeError, () => {
|
||||||
//CHECK#1
|
new Error.prototype();
|
||||||
try {
|
throw new Test262Error();
|
||||||
var __instance = new Error.prototype;
|
});
|
||||||
throw new Test262Error('#1: "var __instance = new Error.prototype" lead to throwing exception');
|
|
||||||
} catch (e) {
|
|
||||||
if (e instanceof Test262Error) throw e;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
@ -15,44 +15,14 @@ var constr = Error.prototype.constructor;
|
|||||||
|
|
||||||
var err = new constr;
|
var err = new constr;
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
assert.notSameValue(err, undefined, 'The value of err is expected to not equal ``undefined``');
|
||||||
// CHECK#0
|
assert.sameValue(err.constructor, Error, 'The value of err.constructor is expected to equal the value of Error');
|
||||||
if (err === undefined) {
|
assert(Error.prototype.isPrototypeOf(err), 'Error.prototype.isPrototypeOf(err) must return true');
|
||||||
throw new Test262Error('#0: constr = Error.prototype.constructor; err = new constr; err === undefined');
|
|
||||||
}
|
|
||||||
//
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
// CHECK#1
|
|
||||||
if (err.constructor !== Error) {
|
|
||||||
throw new Test262Error('#1: constr = Error.prototype.constructor; err = new constr; err.constructor === Error. Actual: ' + err.constructor);
|
|
||||||
}
|
|
||||||
//
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
// CHECK#2
|
|
||||||
if (!(Error.prototype.isPrototypeOf(err))) {
|
|
||||||
throw new Test262Error('#2: constr = Error.prototype.constructor; err = new constr; Error.prototype.isPrototypeOf(err) return true. Actual: ' + Error.prototype.isPrototypeOf(err));
|
|
||||||
}
|
|
||||||
//
|
//
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
// CHECK#3
|
// CHECK#3
|
||||||
Error.prototype.toString = Object.prototype.toString;
|
Error.prototype.toString = Object.prototype.toString;
|
||||||
var to_string_result = '[object ' + 'Error' + ']';
|
assert.sameValue(err.toString(), '[object Error]', 'err.toString() must return "[object Error]"');
|
||||||
if (err.toString() !== to_string_result) {
|
assert.sameValue(err.valueOf().toString(), '[object Error]', 'err.valueOf().toString() must return "[object Error]"');
|
||||||
throw new Test262Error('#3: constr = Error.prototype.constructor; err = new constr; Error.prototype.toString=Object.prototype.toString; err.toString() === \'[object Error]\'. Actual: ' + err.toString());
|
|
||||||
}
|
|
||||||
//
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
// CHECK#4
|
|
||||||
if (err.valueOf().toString() !== to_string_result) {
|
|
||||||
throw new Test262Error('#4: constr = Error.prototype.constructor; err = new constr; Error.prototype.toString=Object.prototype.toString; err.valueOf().toString() === \'[object Error]\'. Actual: ' + err.valueOf().toString());
|
|
||||||
}
|
|
||||||
//
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
@ -4,20 +4,7 @@
|
|||||||
/*---
|
/*---
|
||||||
info: The Error.prototype.toString returns an implementation defined string
|
info: The Error.prototype.toString returns an implementation defined string
|
||||||
es5id: 15.11.4.4_A2
|
es5id: 15.11.4.4_A2
|
||||||
description: Checking if call of Error.prototype.toSting() fails
|
description: Checking if call of Error.prototype.toString() fails
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
assert.notSameValue(new Error("Error").toString(), undefined, 'The value of toStr is expected to not equal ``undefined``');
|
||||||
// CHECK#1
|
|
||||||
var err1 = new Error("Error");
|
|
||||||
try {
|
|
||||||
var toStr = err1.toString();
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
throw new Test262Error('#1: var err1=new Error("Error"); var toStr=err1.toString(); lead to throwing exception. Exception is ' + e);
|
|
||||||
}
|
|
||||||
if (toStr === undefined) {
|
|
||||||
throw new Test262Error('#2: var err1=new Error("Error"); var toStr=err1.toString(); toStr!==undefined. Actual: ' + toStr);
|
|
||||||
}
|
|
||||||
//
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user