Transform legacy format to harness assertions: test/built-ins/E*/**/*.js

This commit is contained in:
rwaldron 2021-08-11 14:48:36 -04:00 committed by Leo Balter
parent f1720c4a0c
commit 1286bb601e
10 changed files with 41 additions and 140 deletions

View File

@ -13,11 +13,11 @@ var proto = Error.prototype;
//CHECK#1
verifyNotConfigurable(Error, "prototype");
try {
if ((delete Error.prototype) !== false) {
throw new Test262Error('#1: Error.prototype has the attribute DontDelete');
}
assert.sameValue(delete Error.prototype, false);
} catch (e) {
if (e instanceof Test262Error) throw e;
if (e instanceof Test262Error) {
throw e;
}
assert(e instanceof TypeError);
}
//
@ -30,3 +30,5 @@ if (Error.prototype !== proto) {
}
//
//////////////////////////////////////////////////////////////////////////////
// TODO: Convert to verifyProperty() format.

View File

@ -6,21 +6,13 @@ info: Error.prototype property has the attributes {DontEnum}
es5id: 15.11.3.1_A2_T1
description: Checking if enumerating the Error.prototype property fails
---*/
assert(Error.hasOwnProperty('prototype'), 'Error.hasOwnProperty(\'prototype\') must return true');
//////////////////////////////////////////////////////////////////////////////
//CHECK#0
if (!(Error.hasOwnProperty('prototype'))) {
throw new Test262Error('#0: Error.hasOwnProperty(\'prototype\') return true. Actual: ' + Error.hasOwnProperty('prototype'));
}
//
//////////////////////////////////////////////////////////////////////////////
assert(
!Error.propertyIsEnumerable('prototype'),
'The value of !Error.propertyIsEnumerable(\'prototype\') is expected to be true'
);
//////////////////////////////////////////////////////////////////////////////
// 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;
for (var p in Error) {
if (p === "prototype") cout++;
if (p === "prototype") {
cout++;
}
}
if (cout !== 0) {
throw new Test262Error('#2: cout === 0. Actual: ' + cout);
}
//
//////////////////////////////////////////////////////////////////////////////
assert.sameValue(cout, 0, 'The value of cout is expected to be 0');
// TODO: Convert to verifyProperty() format.

View File

@ -7,14 +7,7 @@ es5id: 15.11.3.1_A3_T1
description: Checking if varying the Error.prototype property fails
includes: [propertyHelper.js]
---*/
//////////////////////////////////////////////////////////////////////////////
//CHECK#1
if (!(Error.hasOwnProperty('prototype'))) {
throw new Test262Error('#1: Error.hasOwnProperty(\'prototype\') return true. Actual: ' + Error.hasOwnProperty('prototype'));
}
//
//////////////////////////////////////////////////////////////////////////////
assert(Error.hasOwnProperty('prototype'));
var __obj = Error.prototype;
@ -22,21 +15,7 @@ verifyNotWritable(Error, "prototype", null, function() {
return "shifted";
});
//////////////////////////////////////////////////////////////////////////////
//CHECK#2
if (Error.prototype !== __obj) {
throw new Test262Error('#2: __obj = Error.prototype; Error.prototype = function(){return "shifted";}; Error.prototype === __obj. Actual: ' + Error.prototype);
}
//
//////////////////////////////////////////////////////////////////////////////
assert.sameValue(Error.prototype, __obj);
// TODO: Convert to verifyProperty() format.
//////////////////////////////////////////////////////////////////////////////
//CHECK#3
try {
Error.prototype();
throw new Test262Error('#3: "Error.prototype()" lead to throwing exception');
} catch (e) {
if (e instanceof Test262Error) throw e;
}
//
//////////////////////////////////////////////////////////////////////////////

View File

@ -6,11 +6,4 @@ info: The Error has property prototype
es5id: 15.11.3.1_A4_T1
description: Checking Error.hasOwnProperty('prototype')
---*/
//////////////////////////////////////////////////////////////////////////////
//CHECK#1
if (!(Error.hasOwnProperty('prototype'))) {
throw new Test262Error('#1: Error.hasOwnProperty(\'prototype\') return true. Actual: ' + Error.hasOwnProperty('prototype'));
}
//
//////////////////////////////////////////////////////////////////////////////
assert(Error.hasOwnProperty('prototype'), 'Error.hasOwnProperty(\'prototype\') must return true');

View File

@ -8,11 +8,7 @@ info: |
es5id: 15.11.4_A1
description: Get Error.prototype and compare with Object.prototype
---*/
//////////////////////////////////////////////////////////////////////////////
// CHECK#1
if (!Object.prototype.isPrototypeOf(Error.prototype)) {
throw new Test262Error('#1: Object.prototype.isPrototypeOf(Error.prototype) return true. Actual: ' + Object.prototype.isPrototypeOf(Error.prototype));
}
//
//////////////////////////////////////////////////////////////////////////////
assert(
Object.prototype.isPrototypeOf(Error.prototype),
'Object.prototype.isPrototypeOf(Error.prototype) must return true'
);

View File

@ -14,10 +14,4 @@ description: >
Error.prototype.toString = Object.prototype.toString;
var __tostr = Error.prototype.toString();
//////////////////////////////////////////////////////////////////////////////
//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);
}
//
//////////////////////////////////////////////////////////////////////////////
assert.sameValue(__tostr, "[object Object]", 'The value of __tostr is expected to be "[object Object]"');

View File

@ -7,13 +7,7 @@ es5id: 15.11.4_A3
description: Checking if call of Error prototype as a function fails
---*/
//////////////////////////////////////////////////////////////////////////////
//CHECK#1
try {
asserts.throws(TypeError, () => {
Error.prototype();
throw new Test262Error('#1: "Error.prototype()" lead to throwing exception');
} catch (e) {
if (e instanceof Test262Error) throw e;
}
//
//////////////////////////////////////////////////////////////////////////////
throw new Test262Error();
});

View File

@ -7,13 +7,7 @@ es5id: 15.11.4_A4
description: Checking if creating "new Error.prototype" fails
---*/
//////////////////////////////////////////////////////////////////////////////
//CHECK#1
try {
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;
}
//
//////////////////////////////////////////////////////////////////////////////
asserts.throws(TypeError, () => {
new Error.prototype();
throw new Test262Error();
});

View File

@ -15,44 +15,14 @@ var constr = Error.prototype.constructor;
var err = new constr;
//////////////////////////////////////////////////////////////////////////////
// CHECK#0
if (err === undefined) {
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));
}
assert.notSameValue(err, undefined, 'The value of err is expected to not equal ``undefined``');
assert.sameValue(err.constructor, Error, 'The value of err.constructor is expected to equal the value of Error');
assert(Error.prototype.isPrototypeOf(err), 'Error.prototype.isPrototypeOf(err) must return true');
//
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// CHECK#3
Error.prototype.toString = Object.prototype.toString;
var to_string_result = '[object ' + 'Error' + ']';
if (err.toString() !== to_string_result) {
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());
}
//
//////////////////////////////////////////////////////////////////////////////
assert.sameValue(err.toString(), '[object Error]', 'err.toString() must return "[object Error]"');
assert.sameValue(err.valueOf().toString(), '[object Error]', 'err.valueOf().toString() must return "[object Error]"');

View File

@ -4,20 +4,7 @@
/*---
info: The Error.prototype.toString returns an implementation defined string
es5id: 15.11.4.4_A2
description: Checking if call of Error.prototype.toSting() fails
description: Checking if call of Error.prototype.toString() fails
---*/
//////////////////////////////////////////////////////////////////////////////
// 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);
}
//
//////////////////////////////////////////////////////////////////////////////
assert.notSameValue(new Error("Error").toString(), undefined, 'The value of toStr is expected to not equal ``undefined``');