mirror of https://github.com/tc39/test262.git
typeof ... fixups
This commit is contained in:
parent
12ca482cd4
commit
511ce3b2c1
|
@ -3,13 +3,50 @@
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
esid: sec-typeof-operator-runtime-semantics-evaluation
|
esid: sec-typeof-operator-runtime-semantics-evaluation
|
||||||
description: typeof of BigInt and BigInt object
|
description: typeof BigInt literal and BigInt object
|
||||||
info: >
|
info: |
|
||||||
The typeof Operator
|
The typeof Operator
|
||||||
|
|
||||||
Runtime Semantics: Evaluation
|
Runtime Semantics: Evaluation
|
||||||
|
|
||||||
|
...
|
||||||
|
Return a String according to Table 35.
|
||||||
|
|
||||||
|
#table-35
|
||||||
|
|
||||||
|
BigInt "bigint"
|
||||||
|
Object(BigInt()) "object"
|
||||||
|
|
||||||
features: [BigInt]
|
features: [BigInt]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
assert.sameValue(typeof 0n, "bigint");
|
assert.sameValue(
|
||||||
assert.sameValue(typeof Object(0n), "object");
|
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'"
|
||||||
|
);
|
||||||
|
|
|
@ -2,26 +2,31 @@
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
info: Result of applying "typeof" operator to boolean is "boolean"
|
esid: sec-typeof-operator-runtime-semantics-evaluation
|
||||||
es5id: 11.4.3_A3.3
|
description: typeof Boolean literal
|
||||||
es6id: 12.5.6.1
|
info: |
|
||||||
description: typeof (boolean value) === "boolean"
|
The typeof Operator
|
||||||
|
|
||||||
|
Runtime Semantics: Evaluation
|
||||||
|
|
||||||
|
...
|
||||||
|
Return a String according to Table 35.
|
||||||
|
|
||||||
|
#table-35
|
||||||
|
|
||||||
|
Boolean "boolean"
|
||||||
|
|
||||||
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
typeof true,
|
typeof true,
|
||||||
"boolean",
|
"boolean",
|
||||||
'#1: typeof true === "boolean". Actual: ' + (typeof true)
|
'typeof true === "boolean"'
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
typeof false,
|
typeof false,
|
||||||
"boolean",
|
"boolean",
|
||||||
'#2: typeof false === "boolean". Actual: ' + (typeof false)
|
'typeof false === "boolean"'
|
||||||
);
|
|
||||||
|
|
||||||
assert.sameValue(
|
|
||||||
typeof !-1,
|
|
||||||
"boolean",
|
|
||||||
'#3: typeof !-1 === "boolean". Actual: ' + (typeof !-1)
|
|
||||||
);
|
);
|
||||||
|
|
|
@ -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"'
|
||||||
|
);
|
||||||
|
|
|
@ -2,22 +2,35 @@
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
info: >
|
esid: sec-typeof-operator-runtime-semantics-evaluation
|
||||||
There are two types of Function objects. Internal functions
|
description: typeof Object (implements [[Call]]) === "function"
|
||||||
are built-in objects of the language, such as parseInt and Math.exp
|
info: |
|
||||||
es5id: 10.1.1_A2_T1
|
The typeof Operator
|
||||||
es6id: 12.5.6.1
|
|
||||||
description: Checking types of parseInt and Math.exp
|
Runtime Semantics: Evaluation
|
||||||
|
|
||||||
|
...
|
||||||
|
Return a String according to Table 35.
|
||||||
|
|
||||||
|
#table-35
|
||||||
|
|
||||||
|
Object (implements [[Call]]) "function"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
typeof Math.exp,
|
typeof Math.exp,
|
||||||
"function",
|
"function",
|
||||||
'#1: typeof Math.exp!=="function" '+typeof Math.exp
|
'typeof Math.exp === "function"'
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
typeof parseInt,
|
typeof parseInt,
|
||||||
"function",
|
"function",
|
||||||
'#2: typeof parseInt!=="function" '+typeof parseInt
|
'typeof parseInt === "function"'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// TODO: should this be expanded to check all built-ins?
|
||||||
|
// that might be excessive...
|
||||||
|
|
|
@ -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"'
|
||||||
|
);
|
|
@ -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;
|
||||||
|
});
|
|
@ -2,28 +2,43 @@
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
info: Operator "typeof" uses GetValue
|
esid: sec-typeof-operator-runtime-semantics-evaluation
|
||||||
es5id: 11.4.3_A2_T1
|
description: Operator "typeof" uses GetValue
|
||||||
es6id: 12.5.6.1
|
info: |
|
||||||
description: Either Type(x) is not Reference or GetBase(x) is not null
|
The typeof Operator
|
||||||
|
|
||||||
|
Runtime Semantics: Evaluation
|
||||||
|
|
||||||
|
...
|
||||||
|
Set val to ? GetValue(val).
|
||||||
|
...
|
||||||
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
assert.sameValue(
|
var count = 0;
|
||||||
typeof 0,
|
|
||||||
"number",
|
Object.defineProperties(this, {
|
||||||
'#1: typeof 0 === "number". Actual: ' + (typeof 0)
|
x: {
|
||||||
);
|
value: 1
|
||||||
|
},
|
||||||
|
y: {
|
||||||
|
get() {
|
||||||
|
count++;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
var x = 0;
|
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
typeof x,
|
typeof x,
|
||||||
"number",
|
"number",
|
||||||
'#2: typeof x === "number". Actual: ' + (typeof x)
|
'typeof x === "number"'
|
||||||
);
|
);
|
||||||
|
|
||||||
var x = new Object();
|
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
typeof x,
|
typeof y,
|
||||||
"object",
|
"number",
|
||||||
'#3: var x = new Object(); typeof x === "object". Actual: ' + (typeof x)
|
'typeof y === "number"'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
assert.sameValue(count, 1);
|
||||||
|
|
|
@ -2,64 +2,75 @@
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
info: >
|
esid: sec-typeof-operator-runtime-semantics-evaluation
|
||||||
Result of applying "typeof" operator to the object that is native and
|
description: typeof Object (implements [[Call]]) === "function"
|
||||||
implements [[Call]] is "function"
|
info: |
|
||||||
es5id: 11.4.3_A3.7
|
The typeof Operator
|
||||||
es6id: 12.5.6.1
|
|
||||||
description: typeof (object with [[Call]]) === "function"
|
Runtime Semantics: Evaluation
|
||||||
|
|
||||||
|
...
|
||||||
|
Return a String according to Table 35.
|
||||||
|
|
||||||
|
#table-35
|
||||||
|
|
||||||
|
Object (implements [[Call]]) "function"
|
||||||
|
|
||||||
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
typeof new Function(),
|
typeof new Function(),
|
||||||
"function",
|
"function",
|
||||||
'#1: typeof new Function() === "function". Actual: ' + (typeof new Function())
|
'typeof new Function() === "function"'
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
typeof Function(),
|
typeof Function(),
|
||||||
"function",
|
"function",
|
||||||
'#2: typeof Function() === "function". Actual: ' + (typeof Function())
|
'typeof Function() === "function"'
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
typeof Object,
|
typeof Object,
|
||||||
"function",
|
"function",
|
||||||
'#3: typeof Object === "function". Actual: ' + (typeof Object)
|
'typeof Object === "function"'
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
typeof String,
|
typeof String,
|
||||||
"function",
|
"function",
|
||||||
'#4: typeof String === "function". Actual: ' + (typeof String)
|
'typeof String === "function"'
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
typeof Boolean,
|
typeof Boolean,
|
||||||
"function",
|
"function",
|
||||||
'#5: typeof Boolean === "function". Actual: ' + (typeof Boolean)
|
'typeof Boolean === "function"'
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
typeof Number,
|
typeof Number,
|
||||||
"function",
|
"function",
|
||||||
'#6: typeof Number === "function". Actual: ' + (typeof Number)
|
'typeof Number === "function"'
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
typeof Date,
|
typeof Date,
|
||||||
"function",
|
"function",
|
||||||
'#7: typeof Date === "function". Actual: ' + (typeof Date)
|
'typeof Date === "function"'
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
typeof Error,
|
typeof Error,
|
||||||
"function",
|
"function",
|
||||||
'#8: typeof Error === "function". Actual: ' + (typeof Error)
|
'typeof Error === "function"'
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
typeof RegExp,
|
typeof RegExp,
|
||||||
"function",
|
"function",
|
||||||
'#9: typeof RegExp === "function". Actual: ' + (typeof RegExp)
|
'typeof RegExp === "function"'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// TODO: Should this be extended to include all built-ins?
|
||||||
|
|
|
@ -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())
|
|
||||||
);
|
|
|
@ -2,20 +2,30 @@
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
info: Result of applying "typeof" operator to null is "object"
|
esid: sec-typeof-operator-runtime-semantics-evaluation
|
||||||
es5id: 11.4.3_A3.2
|
description: typeof Object (implements [[Call]]) === "function"
|
||||||
es6id: 12.5.6.1
|
info: |
|
||||||
description: typeof null === "object"
|
The typeof Operator
|
||||||
|
|
||||||
|
Runtime Semantics: Evaluation
|
||||||
|
|
||||||
|
...
|
||||||
|
Return a String according to Table 35.
|
||||||
|
|
||||||
|
#table-35
|
||||||
|
|
||||||
|
Null "object"
|
||||||
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
typeof null,
|
typeof null,
|
||||||
"object",
|
"object",
|
||||||
'#1: typeof null === "object". Actual: ' + (typeof null)
|
'typeof null === "object"'
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
typeof RegExp("0").exec("1"),
|
typeof RegExp("0").exec("1"),
|
||||||
"object",
|
"object",
|
||||||
'#2: typeof RegExp("0").exec("1") === "object". Actual: ' + (typeof RegExp("0").exec("1"))
|
'typeof RegExp("0").exec("1") === "object"'
|
||||||
);
|
);
|
||||||
|
|
|
@ -2,38 +2,48 @@
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
info: Result of appying "typeof" operator to number is "number"
|
esid: sec-typeof-operator-runtime-semantics-evaluation
|
||||||
es5id: 11.4.3_A3.4
|
description: typeof Number literal
|
||||||
es6id: 12.5.6.1
|
info: |
|
||||||
description: typeof (number value) === "number"
|
The typeof Operator
|
||||||
|
|
||||||
|
Runtime Semantics: Evaluation
|
||||||
|
|
||||||
|
...
|
||||||
|
Return a String according to Table 35.
|
||||||
|
|
||||||
|
#table-35
|
||||||
|
|
||||||
|
Number "number"
|
||||||
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
typeof 1,
|
typeof 1,
|
||||||
"number",
|
"number",
|
||||||
'typeof 1 === "number". Actual: ' + (typeof 1)
|
'typeof 1 === "number"'
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
typeof NaN,
|
typeof NaN,
|
||||||
"number",
|
"number",
|
||||||
'typeof NaN === "number". Actual: ' + (typeof NaN)
|
'typeof NaN === "number"'
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
typeof Infinity,
|
typeof Infinity,
|
||||||
"number",
|
"number",
|
||||||
'typeof Infinity === "number". Actual: ' + (typeof Infinity)
|
'typeof Infinity === "number"'
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
typeof -Infinity,
|
typeof -Infinity,
|
||||||
"number",
|
"number",
|
||||||
'typeof -Infinity === "number". Actual: ' + (typeof -Infinity)
|
'typeof -Infinity === "number"'
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
typeof Math.PI,
|
typeof Math.PI,
|
||||||
"number",
|
"number",
|
||||||
'typeof Math.PI === "number". Actual: ' + (typeof Math.PI)
|
'typeof Math.PI === "number"'
|
||||||
);
|
);
|
||||||
|
|
|
@ -2,44 +2,54 @@
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
info: Result of appying "typeof" operator to string is "string"
|
esid: sec-typeof-operator-runtime-semantics-evaluation
|
||||||
es5id: 11.4.3_A3.5
|
description: typeof String literal
|
||||||
es6id: 12.5.6.1
|
info: |
|
||||||
description: typeof (string value) === "string"
|
The typeof Operator
|
||||||
|
|
||||||
|
Runtime Semantics: Evaluation
|
||||||
|
|
||||||
|
...
|
||||||
|
Return a String according to Table 35.
|
||||||
|
|
||||||
|
#table-35
|
||||||
|
|
||||||
|
String "string"
|
||||||
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
typeof "1",
|
typeof "1",
|
||||||
"string",
|
"string",
|
||||||
'#1: typeof "1" === "string". Actual: ' + (typeof "1")
|
'typeof "1" === "string"'
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
typeof "NaN",
|
typeof "NaN",
|
||||||
"string",
|
"string",
|
||||||
'#2: typeof "NaN" === "string". Actual: ' + (typeof "NaN")
|
'typeof "NaN" === "string"'
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
typeof "Infinity",
|
typeof "Infinity",
|
||||||
"string",
|
"string",
|
||||||
'#3: typeof "Infinity" === "string". Actual: ' + (typeof "Infinity")
|
'typeof "Infinity" === "string"'
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
typeof "",
|
typeof "",
|
||||||
"string",
|
"string",
|
||||||
'#4: typeof "" === "string". Actual: ' + (typeof "")
|
'typeof "" === "string"'
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
typeof "true",
|
typeof "true",
|
||||||
"string",
|
"string",
|
||||||
'#5: typeof "true" === "string". Actual: ' + (typeof "true")
|
'typeof "true" === "string"'
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
typeof Date(),
|
typeof Date(),
|
||||||
"string",
|
"string",
|
||||||
'#6: typeof Date() === "string". Actual: ' + (typeof Date())
|
'typeof Date() === "string"'
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,18 +1,45 @@
|
||||||
// Copyright (C) 2013 the V8 project authors. All rights reserved.
|
// Copyright (C) 2013 the V8 project authors. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
/*---
|
/*---
|
||||||
es6id: 12.5.6.1
|
esid: sec-typeof-operator-runtime-semantics-evaluation
|
||||||
description: >
|
description: typeof Symbol() and Object(Symbol)
|
||||||
typeof Symbol() returns 'symbol'.
|
info: |
|
||||||
typeof Object(Symbol()) returns 'object'.
|
The typeof Operator
|
||||||
|
|
||||||
|
Runtime Semantics: Evaluation
|
||||||
|
|
||||||
|
...
|
||||||
|
Return a String according to Table 35.
|
||||||
|
|
||||||
|
#table-35
|
||||||
|
|
||||||
|
Symbol "symbol"
|
||||||
|
Object(Symbol()) "object"
|
||||||
|
|
||||||
features: [Symbol]
|
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(
|
||||||
assert.sameValue(typeof symA, 'symbol', "`typeof symA` is `'symbol'`, after executing `var symA = Symbol();`");
|
typeof Symbol(),
|
||||||
|
"symbol",
|
||||||
|
"typeof Symbol() === 'symbol'"
|
||||||
|
);
|
||||||
|
|
||||||
var symB = Object(Symbol());
|
assert.sameValue(
|
||||||
assert.sameValue(typeof symB, 'object', "`typeof symB` is `'object'`, after executing `var symB = Object(Symbol());`");
|
typeof Symbol("A"),
|
||||||
|
"symbol",
|
||||||
|
"typeof Symbol('A') === 'symbol'"
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
typeof Object(Symbol()),
|
||||||
|
"object",
|
||||||
|
"typeof Object(Symbol()) === 'object'"
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
typeof Object(Symbol("A")),
|
||||||
|
"object",
|
||||||
|
"typeof Object(Symbol('A')) === 'object'"
|
||||||
|
);
|
||||||
|
|
||||||
|
|
|
@ -2,20 +2,29 @@
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
info: Result of applying "typeof" operator to undefined is "undefined"
|
esid: sec-typeof-operator-runtime-semantics-evaluation
|
||||||
es5id: 11.4.3_A3.1
|
description: typeof undefined and void 0
|
||||||
es6id: 12.5.6.1
|
info: |
|
||||||
description: typeof undefined === "undefined"
|
The typeof Operator
|
||||||
|
|
||||||
|
Runtime Semantics: Evaluation
|
||||||
|
|
||||||
|
...
|
||||||
|
Return a String according to Table 35.
|
||||||
|
|
||||||
|
#table-35
|
||||||
|
|
||||||
|
Undefined "undefined"
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
typeof undefined,
|
typeof undefined,
|
||||||
"undefined",
|
"undefined",
|
||||||
'#1: typeof undefined === "undefined". Actual: ' + (typeof undefined)
|
'typeof undefined === "undefined"'
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
typeof void 0,
|
typeof void 0,
|
||||||
"undefined",
|
"undefined",
|
||||||
'#2: typeof void 0 === "undefined". Actual: ' + (typeof void 0)
|
'typeof void 0 === "undefined"'
|
||||||
);
|
);
|
||||||
|
|
|
@ -2,12 +2,22 @@
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
info: Operator "typeof" uses GetValue
|
esid: sec-typeof-operator-runtime-semantics-evaluation
|
||||||
es5id: 11.4.3_A2_T2
|
description: If IsUnresolvableReference(val) is true, return "undefined".
|
||||||
es6id: 12.5.6.1
|
info: |
|
||||||
description: If GetBase(x) is null, return "undefined"
|
The typeof Operator
|
||||||
|
|
||||||
|
Runtime Semantics: Evaluation
|
||||||
|
|
||||||
|
...
|
||||||
|
If Type(val) is Reference, then
|
||||||
|
If IsUnresolvableReference(val) is true, return "undefined".
|
||||||
|
...
|
||||||
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
typeof x, "undefined", '#1: typeof x === "undefined". Actual: ' + (typeof x)
|
typeof x,
|
||||||
|
"undefined",
|
||||||
|
"typeof x === 'undefined'"
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue