diff --git a/test/language/expressions/typeof/bigint.js b/test/language/expressions/typeof/bigint.js index 4bf70988e053ccbe82f7916dabdda25461664bf3..d8bda8b9ac215d6accb60f854c6ea50edd181ac9 100644 --- a/test/language/expressions/typeof/bigint.js +++ b/test/language/expressions/typeof/bigint.js @@ -3,13 +3,50 @@ /*--- esid: sec-typeof-operator-runtime-semantics-evaluation -description: typeof of BigInt and BigInt object -info: > +description: typeof BigInt literal and BigInt object +info: | The typeof Operator Runtime Semantics: Evaluation + + ... + Return a String according to Table 35. + + #table-35 + + BigInt "bigint" + Object(BigInt()) "object" + features: [BigInt] ---*/ -assert.sameValue(typeof 0n, "bigint"); -assert.sameValue(typeof Object(0n), "object"); +assert.sameValue( + typeof 0n, + "bigint", + "typeof 0n === 'bigint'" +); +assert.sameValue( + typeof BigInt(0n), + "bigint", + "typeof BigInt(0n) === 'bigint'" +); +assert.sameValue( + typeof BigInt(0), + "bigint", + "typeof BigInt(0) === 'bigint'" +); +assert.sameValue( + typeof Object(BigInt(0n)), + "object", + "typeof Object(BigInt(0n)) === 'object'" +); +assert.sameValue( + typeof Object(BigInt(0)), + "object", + "typeof Object(BigInt(0)) === 'object'" +); +assert.sameValue( + typeof Object(0n), + "object", + "typeof Object(0n) === 'object'" +); diff --git a/test/language/expressions/typeof/boolean.js b/test/language/expressions/typeof/boolean.js index 5e5f184b10c84e6f4790b9b9439268ca50ed13d2..93e9a4e8b9f6b745331c4302882634aa536ce491 100644 --- a/test/language/expressions/typeof/boolean.js +++ b/test/language/expressions/typeof/boolean.js @@ -2,26 +2,31 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -info: Result of applying "typeof" operator to boolean is "boolean" -es5id: 11.4.3_A3.3 -es6id: 12.5.6.1 -description: typeof (boolean value) === "boolean" +esid: sec-typeof-operator-runtime-semantics-evaluation +description: typeof Boolean literal +info: | + The typeof Operator + + Runtime Semantics: Evaluation + + ... + Return a String according to Table 35. + + #table-35 + + Boolean "boolean" + + ---*/ assert.sameValue( typeof true, "boolean", - '#1: typeof true === "boolean". Actual: ' + (typeof true) + 'typeof true === "boolean"' ); assert.sameValue( typeof false, "boolean", - '#2: typeof false === "boolean". Actual: ' + (typeof false) -); - -assert.sameValue( - typeof !-1, - "boolean", - '#3: typeof !-1 === "boolean". Actual: ' + (typeof !-1) + 'typeof false === "boolean"' ); diff --git a/test/language/expressions/typeof/built-in-exotic-objects-no-call.js b/test/language/expressions/typeof/built-in-exotic-objects-no-call.js new file mode 100644 index 0000000000000000000000000000000000000000..0aab11917034e7fdf7f2df714348038e4f3972fb --- /dev/null +++ b/test/language/expressions/typeof/built-in-exotic-objects-no-call.js @@ -0,0 +1,75 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-typeof-operator-runtime-semantics-evaluation +description: typeof Object (standard exotic and does not implement [[Call]]) === "object" +info: | + The typeof Operator + + Runtime Semantics: Evaluation + + ... + Return a String according to Table 35. + + #table-35 + + Object (standard exotic and does not implement [[Call]]) "object" + + +---*/ + +assert.sameValue( + typeof this, + "object", + 'typeof this === "object"' +); + +assert.sameValue( + typeof new Object(), + "object", + 'typeof new Object() === "object"' +); + +assert.sameValue( + typeof new Array(), + "object", + 'typeof new Array() === "object"' +); + +assert.sameValue( + typeof new String(), + "object", + 'typeof new String() === "object"' +); + +assert.sameValue( + typeof new Boolean(), + "object", + 'typeof new Boolean() === "object"' +); + +assert.sameValue( + typeof new Number(), + "object", + 'typeof new Number() === "object"' +); + +assert.sameValue( + typeof new Date(), + "object", + 'typeof new Date() === "object"' +); + +assert.sameValue( + typeof new Error(), + "object", + ' typeof new Error() === "object"' +); + +assert.sameValue( + typeof new RegExp(), + "object", + ' typeof new RegExp() === "object"' +); + diff --git a/test/language/expressions/typeof/built-in-functions.js b/test/language/expressions/typeof/built-in-functions.js index 2e0dcc2d6cdeba050bf7646484bd82f3108172a8..d20450ed8c3411f5b3d0d85dfc4610732c1b3f44 100644 --- a/test/language/expressions/typeof/built-in-functions.js +++ b/test/language/expressions/typeof/built-in-functions.js @@ -2,22 +2,35 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -info: > - There are two types of Function objects. Internal functions - are built-in objects of the language, such as parseInt and Math.exp -es5id: 10.1.1_A2_T1 -es6id: 12.5.6.1 -description: Checking types of parseInt and Math.exp +esid: sec-typeof-operator-runtime-semantics-evaluation +description: typeof Object (implements [[Call]]) === "function" +info: | + The typeof Operator + + Runtime Semantics: Evaluation + + ... + Return a String according to Table 35. + + #table-35 + + Object (implements [[Call]]) "function" + + + ---*/ assert.sameValue( typeof Math.exp, "function", - '#1: typeof Math.exp!=="function" '+typeof Math.exp + 'typeof Math.exp === "function"' ); assert.sameValue( typeof parseInt, "function", - '#2: typeof parseInt!=="function" '+typeof parseInt + 'typeof parseInt === "function"' ); + +// TODO: should this be expanded to check all built-ins? +// that might be excessive... diff --git a/test/language/expressions/typeof/built-in-ordinary-objects-no-call.js b/test/language/expressions/typeof/built-in-ordinary-objects-no-call.js new file mode 100644 index 0000000000000000000000000000000000000000..2f7c18b62cec6402e2d7dd2849669b9b7c14c9d9 --- /dev/null +++ b/test/language/expressions/typeof/built-in-ordinary-objects-no-call.js @@ -0,0 +1,31 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-typeof-operator-runtime-semantics-evaluation +description: typeof Object (ordinary and does not implement [[Call]]) === "object" +info: | + The typeof Operator + + Runtime Semantics: Evaluation + + ... + Return a String according to Table 35. + + #table-35 + + Object (ordinary and does not implement [[Call]]) "object" + +---*/ + +assert.sameValue( + typeof Math, + "object", + 'typeof Math === "object"' +); + +assert.sameValue( + typeof Reflect, + "object", + 'typeof Reflect === "object"' +); diff --git a/test/language/expressions/typeof/get-value-ref-err.js b/test/language/expressions/typeof/get-value-ref-err.js new file mode 100644 index 0000000000000000000000000000000000000000..49ddecb379ccb3272be5696974dec8d360e35e50 --- /dev/null +++ b/test/language/expressions/typeof/get-value-ref-err.js @@ -0,0 +1,25 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-typeof-operator-runtime-semantics-evaluation +description: Operator "typeof" uses GetValue +info: | + The typeof Operator + + Runtime Semantics: Evaluation + + ... + Set val to ? GetValue(val). + ... + + GetValue ( V ): + + ... + If IsUnresolvableReference(V) is true, throw a ReferenceError exception. + +---*/ + +assert.throws(ReferenceError, function() { + typeof x.x; +}); diff --git a/test/language/expressions/typeof/get-value.js b/test/language/expressions/typeof/get-value.js index 2e52c0caa1e0952b818d17e9d6a8a6fdd89ba645..8b53e91d8566d932eeeb2613c08f9b080501f549 100644 --- a/test/language/expressions/typeof/get-value.js +++ b/test/language/expressions/typeof/get-value.js @@ -2,28 +2,43 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -info: Operator "typeof" uses GetValue -es5id: 11.4.3_A2_T1 -es6id: 12.5.6.1 -description: Either Type(x) is not Reference or GetBase(x) is not null +esid: sec-typeof-operator-runtime-semantics-evaluation +description: Operator "typeof" uses GetValue +info: | + The typeof Operator + + Runtime Semantics: Evaluation + + ... + Set val to ? GetValue(val). + ... + ---*/ -assert.sameValue( - typeof 0, - "number", - '#1: typeof 0 === "number". Actual: ' + (typeof 0) -); +var count = 0; + +Object.defineProperties(this, { + x: { + value: 1 + }, + y: { + get() { + count++; + return 1; + } + } +}); -var x = 0; assert.sameValue( typeof x, "number", - '#2: typeof x === "number". Actual: ' + (typeof x) + 'typeof x === "number"' ); -var x = new Object(); assert.sameValue( - typeof x, - "object", - '#3: var x = new Object(); typeof x === "object". Actual: ' + (typeof x) + typeof y, + "number", + 'typeof y === "number"' ); + +assert.sameValue(count, 1); diff --git a/test/language/expressions/typeof/native-call.js b/test/language/expressions/typeof/native-call.js index a4508e8798934e2b26f615cee66737ab3f449d37..1d192bec8822a9921a1f7282a886696c1ce0371d 100644 --- a/test/language/expressions/typeof/native-call.js +++ b/test/language/expressions/typeof/native-call.js @@ -2,64 +2,75 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -info: > - Result of applying "typeof" operator to the object that is native and - implements [[Call]] is "function" -es5id: 11.4.3_A3.7 -es6id: 12.5.6.1 -description: typeof (object with [[Call]]) === "function" +esid: sec-typeof-operator-runtime-semantics-evaluation +description: typeof Object (implements [[Call]]) === "function" +info: | + The typeof Operator + + Runtime Semantics: Evaluation + + ... + Return a String according to Table 35. + + #table-35 + + Object (implements [[Call]]) "function" + + ---*/ assert.sameValue( typeof new Function(), "function", - '#1: typeof new Function() === "function". Actual: ' + (typeof new Function()) + 'typeof new Function() === "function"' ); assert.sameValue( typeof Function(), "function", - '#2: typeof Function() === "function". Actual: ' + (typeof Function()) + 'typeof Function() === "function"' ); assert.sameValue( typeof Object, "function", - '#3: typeof Object === "function". Actual: ' + (typeof Object) + 'typeof Object === "function"' ); assert.sameValue( typeof String, "function", - '#4: typeof String === "function". Actual: ' + (typeof String) + 'typeof String === "function"' ); assert.sameValue( typeof Boolean, "function", - '#5: typeof Boolean === "function". Actual: ' + (typeof Boolean) + 'typeof Boolean === "function"' ); assert.sameValue( typeof Number, "function", - '#6: typeof Number === "function". Actual: ' + (typeof Number) + 'typeof Number === "function"' ); assert.sameValue( typeof Date, "function", - '#7: typeof Date === "function". Actual: ' + (typeof Date) + 'typeof Date === "function"' ); assert.sameValue( typeof Error, "function", - '#8: typeof Error === "function". Actual: ' + (typeof Error) + 'typeof Error === "function"' ); assert.sameValue( typeof RegExp, "function", - '#9: typeof RegExp === "function". Actual: ' + (typeof RegExp) + 'typeof RegExp === "function"' ); + +// TODO: Should this be extended to include all built-ins? diff --git a/test/language/expressions/typeof/native-no-call.js b/test/language/expressions/typeof/native-no-call.js deleted file mode 100644 index 54401573c3b1c7c47de0dcbd61bb0f148dea4132..0000000000000000000000000000000000000000 --- a/test/language/expressions/typeof/native-no-call.js +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright 2009 the Sputnik authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -info: > - Result of applying "typeof" operator to the object that is native and - doesn't implement [[Call]] is "object" -es5id: 11.4.3_A3.6 -es6id: 12.5.6.1 -description: typeof (object without [[Call]]) === "object" ----*/ - -assert.sameValue( - typeof this, - "object", - '#1: typeof this === "object". Actual: ' + (typeof this) -); - -assert.sameValue( - typeof new Object(), - "object", - '#2: typeof new Object() === "object". Actual: ' + (typeof new Object()) -); - -assert.sameValue( - typeof new Array(1,2,3), - "object", - '#3: typeof new Array(1,2,3) === "object". Actual: ' + (typeof new Array(1,2,3)) -); - -assert.sameValue( - typeof Array(1,2,3), - "object", - '#4: typeof Array(1,2,3) === "object". Actual: ' + (typeof Array(1,2,3)) -); - -assert.sameValue( - typeof new String("x"), - "object", - '#5: typeof new String("x") === "object". Actual: ' + (typeof new String("x")) -); - -assert.sameValue( - typeof new Boolean(true), - "object", - '#6: typeof new Boolean(true) === "object". Actual: ' + (typeof new Boolean(true)) -); - -assert.sameValue( - typeof new Number(1), - "object", - '#7: typeof new Number(1) === "object". Actual: ' + (typeof new Number(1)) -); - -//The Math object does not have a [[Construct]] property; -//it is not possible to use the Math object as a constructor with the new operator. -//The Math object does not have a [[Call]] property; it is not possible to invoke the Math object as a object. -assert.sameValue( - typeof Math, - "object", - '#8: typeof Math === "object". Actual: ' + (typeof Math) -); - -assert.sameValue( - typeof new Date(), - "object", - '#9: typeof new Date() === "object". Actual: ' + (typeof new Date()) -); - -assert.sameValue( - typeof new Error(), - "object", - '#10: typeof new Error() === "object". Actual: ' + (typeof new Error()) -); - -assert.sameValue( - typeof new RegExp(), - "object", - '#11: typeof new RegExp() === "object". Actual: ' + (typeof new RegExp()) -); - -assert.sameValue( - typeof RegExp(), - "object", - '#12: typeof RegExp() === "object". Actual: ' + (typeof RegExp()) -); diff --git a/test/language/expressions/typeof/null.js b/test/language/expressions/typeof/null.js index 9f81ea1470ed4c734bac3193783cd49764cc89cd..67214a4c4b1fd443e6ab88bee9494bfaa9f2f332 100644 --- a/test/language/expressions/typeof/null.js +++ b/test/language/expressions/typeof/null.js @@ -2,20 +2,30 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -info: Result of applying "typeof" operator to null is "object" -es5id: 11.4.3_A3.2 -es6id: 12.5.6.1 -description: typeof null === "object" +esid: sec-typeof-operator-runtime-semantics-evaluation +description: typeof Object (implements [[Call]]) === "function" +info: | + The typeof Operator + + Runtime Semantics: Evaluation + + ... + Return a String according to Table 35. + + #table-35 + + Null "object" + ---*/ assert.sameValue( typeof null, "object", - '#1: typeof null === "object". Actual: ' + (typeof null) + 'typeof null === "object"' ); assert.sameValue( typeof RegExp("0").exec("1"), "object", - '#2: typeof RegExp("0").exec("1") === "object". Actual: ' + (typeof RegExp("0").exec("1")) + 'typeof RegExp("0").exec("1") === "object"' ); diff --git a/test/language/expressions/typeof/number.js b/test/language/expressions/typeof/number.js index bc1f87cecf625e5659b7436d35d2233116d5cd52..eae0a394ae38706abd288209b73af54abef12ae4 100644 --- a/test/language/expressions/typeof/number.js +++ b/test/language/expressions/typeof/number.js @@ -2,38 +2,48 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -info: Result of appying "typeof" operator to number is "number" -es5id: 11.4.3_A3.4 -es6id: 12.5.6.1 -description: typeof (number value) === "number" +esid: sec-typeof-operator-runtime-semantics-evaluation +description: typeof Number literal +info: | + The typeof Operator + + Runtime Semantics: Evaluation + + ... + Return a String according to Table 35. + + #table-35 + + Number "number" + ---*/ assert.sameValue( typeof 1, "number", - 'typeof 1 === "number". Actual: ' + (typeof 1) + 'typeof 1 === "number"' ); assert.sameValue( typeof NaN, "number", - 'typeof NaN === "number". Actual: ' + (typeof NaN) + 'typeof NaN === "number"' ); assert.sameValue( typeof Infinity, "number", - 'typeof Infinity === "number". Actual: ' + (typeof Infinity) + 'typeof Infinity === "number"' ); assert.sameValue( typeof -Infinity, "number", - 'typeof -Infinity === "number". Actual: ' + (typeof -Infinity) + 'typeof -Infinity === "number"' ); assert.sameValue( typeof Math.PI, "number", - 'typeof Math.PI === "number". Actual: ' + (typeof Math.PI) + 'typeof Math.PI === "number"' ); diff --git a/test/language/expressions/typeof/string.js b/test/language/expressions/typeof/string.js index c5c5fbd0450bb166690d0e5788e322c417fdd29e..3278e25777b5b111a2d614976925576cf63df6d5 100644 --- a/test/language/expressions/typeof/string.js +++ b/test/language/expressions/typeof/string.js @@ -2,44 +2,54 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -info: Result of appying "typeof" operator to string is "string" -es5id: 11.4.3_A3.5 -es6id: 12.5.6.1 -description: typeof (string value) === "string" +esid: sec-typeof-operator-runtime-semantics-evaluation +description: typeof String literal +info: | + The typeof Operator + + Runtime Semantics: Evaluation + + ... + Return a String according to Table 35. + + #table-35 + + String "string" + ---*/ assert.sameValue( typeof "1", "string", - '#1: typeof "1" === "string". Actual: ' + (typeof "1") + 'typeof "1" === "string"' ); assert.sameValue( typeof "NaN", "string", - '#2: typeof "NaN" === "string". Actual: ' + (typeof "NaN") + 'typeof "NaN" === "string"' ); assert.sameValue( typeof "Infinity", "string", - '#3: typeof "Infinity" === "string". Actual: ' + (typeof "Infinity") + 'typeof "Infinity" === "string"' ); assert.sameValue( typeof "", "string", - '#4: typeof "" === "string". Actual: ' + (typeof "") + 'typeof "" === "string"' ); assert.sameValue( typeof "true", "string", - '#5: typeof "true" === "string". Actual: ' + (typeof "true") + 'typeof "true" === "string"' ); assert.sameValue( typeof Date(), "string", - '#6: typeof Date() === "string". Actual: ' + (typeof Date()) + 'typeof Date() === "string"' ); diff --git a/test/language/expressions/typeof/symbol.js b/test/language/expressions/typeof/symbol.js index 93e8a1ca9a9f6d8a8de3903fceb0e35822367488..0e0981350816014ee510067416a34a2312f5efd9 100644 --- a/test/language/expressions/typeof/symbol.js +++ b/test/language/expressions/typeof/symbol.js @@ -1,18 +1,45 @@ // Copyright (C) 2013 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -es6id: 12.5.6.1 -description: > - typeof Symbol() returns 'symbol'. - typeof Object(Symbol()) returns 'object'. +esid: sec-typeof-operator-runtime-semantics-evaluation +description: typeof Symbol() and Object(Symbol) +info: | + The typeof Operator + + Runtime Semantics: Evaluation + + ... + Return a String according to Table 35. + + #table-35 + + Symbol "symbol" + Object(Symbol()) "object" + features: [Symbol] ---*/ -assert.sameValue(typeof Symbol('A'), 'symbol', "`typeof Symbol('A')` is `'symbol'`"); -assert.sameValue(typeof Symbol(), 'symbol', "`typeof Symbol()` is `'symbol'`"); -var symA = Symbol(); -assert.sameValue(typeof symA, 'symbol', "`typeof symA` is `'symbol'`, after executing `var symA = Symbol();`"); +assert.sameValue( + typeof Symbol(), + "symbol", + "typeof Symbol() === 'symbol'" +); + +assert.sameValue( + typeof Symbol("A"), + "symbol", + "typeof Symbol('A') === 'symbol'" +); + +assert.sameValue( + typeof Object(Symbol()), + "object", + "typeof Object(Symbol()) === 'object'" +); -var symB = Object(Symbol()); -assert.sameValue(typeof symB, 'object', "`typeof symB` is `'object'`, after executing `var symB = Object(Symbol());`"); +assert.sameValue( + typeof Object(Symbol("A")), + "object", + "typeof Object(Symbol('A')) === 'object'" +); diff --git a/test/language/expressions/typeof/undefined.js b/test/language/expressions/typeof/undefined.js index 77eaf78321a4d4f9ce38b3af2bfc4334636a8a97..ca8530fd308639abde004213e87b981e6755655f 100644 --- a/test/language/expressions/typeof/undefined.js +++ b/test/language/expressions/typeof/undefined.js @@ -2,20 +2,29 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -info: Result of applying "typeof" operator to undefined is "undefined" -es5id: 11.4.3_A3.1 -es6id: 12.5.6.1 -description: typeof undefined === "undefined" +esid: sec-typeof-operator-runtime-semantics-evaluation +description: typeof undefined and void 0 +info: | + The typeof Operator + + Runtime Semantics: Evaluation + + ... + Return a String according to Table 35. + + #table-35 + + Undefined "undefined" ---*/ assert.sameValue( typeof undefined, "undefined", - '#1: typeof undefined === "undefined". Actual: ' + (typeof undefined) + 'typeof undefined === "undefined"' ); assert.sameValue( typeof void 0, "undefined", - '#2: typeof void 0 === "undefined". Actual: ' + (typeof void 0) + 'typeof void 0 === "undefined"' ); diff --git a/test/language/expressions/typeof/unresolvable-reference.js b/test/language/expressions/typeof/unresolvable-reference.js index 333cc9ac84690fcb8394bbf1ed50e45e12a92c79..bf0b03b0a99051a834002541493757d11d5aa05c 100644 --- a/test/language/expressions/typeof/unresolvable-reference.js +++ b/test/language/expressions/typeof/unresolvable-reference.js @@ -2,12 +2,22 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -info: Operator "typeof" uses GetValue -es5id: 11.4.3_A2_T2 -es6id: 12.5.6.1 -description: If GetBase(x) is null, return "undefined" +esid: sec-typeof-operator-runtime-semantics-evaluation +description: If IsUnresolvableReference(val) is true, return "undefined". +info: | + The typeof Operator + + Runtime Semantics: Evaluation + + ... + If Type(val) is Reference, then + If IsUnresolvableReference(val) is true, return "undefined". + ... + ---*/ assert.sameValue( - typeof x, "undefined", '#1: typeof x === "undefined". Actual: ' + (typeof x) + typeof x, + "undefined", + "typeof x === 'undefined'" );