mirror of https://github.com/tc39/test262.git
Merge pull request #221 from bocoup/typeof
Update tests for `typeof` operator
This commit is contained in:
commit
afa25f6cdc
|
@ -1,60 +0,0 @@
|
|||
// Copyright 2009 the Sputnik authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
info: >
|
||||
White Space and Line Terminator between "typeof" and UnaryExpression are
|
||||
allowed
|
||||
es5id: 11.4.3_A1
|
||||
description: Checking by using eval
|
||||
---*/
|
||||
|
||||
//CHECK#1
|
||||
if (eval("var x = 0; typeof\u0009x") !== "number") {
|
||||
$ERROR('#1: var x = 0; typeof\\u0009x; x === "number". Actual: ' + (x));
|
||||
}
|
||||
|
||||
//CHECK#2
|
||||
if (eval("var x = 0; typeof\u000Bx") !== "number") {
|
||||
$ERROR('#2: var x = 0; typeof\\u000Bx; x === "number". Actual: ' + (x));
|
||||
}
|
||||
|
||||
//CHECK#3
|
||||
if (eval("var x = 0; typeof\u000Cx") !== "number") {
|
||||
$ERROR('#3: var x = 0; typeof\\u000Cx; x === "number". Actual: ' + (x));
|
||||
}
|
||||
|
||||
//CHECK#4
|
||||
if (eval("var x = 0; typeof\u0020x") !== "number") {
|
||||
$ERROR('#4: var x = 0; typeof\\u0020x; x === "number". Actual: ' + (x));
|
||||
}
|
||||
|
||||
//CHECK#5
|
||||
if (eval("var x = 0; typeof\u00A0x") !== "number") {
|
||||
$ERROR('#5: var x = 0; typeof\\u00A0x; x === "number". Actual: ' + (x));
|
||||
}
|
||||
|
||||
//CHECK#6
|
||||
if (eval("var x = 0; typeof\u000Ax") !== "number") {
|
||||
$ERROR('#6: var x = 0; typeof\\u000Ax; x === "number". Actual: ' + (x));
|
||||
}
|
||||
|
||||
//CHECK#7
|
||||
if (eval("var x = 0; typeof\u000Dx") !== "number") {
|
||||
$ERROR('#7: var x = 0; typeof\\u000Dx; x === "number". Actual: ' + (x));
|
||||
}
|
||||
|
||||
//CHECK#8
|
||||
if (eval("var x = 0; typeof\u2028x") !== "number") {
|
||||
$ERROR('#8: var x = 0; typeof\\u2028x; x === "number". Actual: ' + (x));
|
||||
}
|
||||
|
||||
//CHECK#9
|
||||
if (eval("var x = 0; typeof\u2029x") !== "number") {
|
||||
$ERROR('#9: var x = 0; typeof\\u2029x; x === "number". Actual: ' + (x));
|
||||
}
|
||||
|
||||
//CHECK#10
|
||||
if (eval("var x = 0; typeof\u0009\u000B\u000C\u0020\u00A0\u000A\u000D\u2028\u2029x") !== "number") {
|
||||
$ERROR('#10: var x = 0; typeof\\u0009\\u000B\\u000C\\u0020\\u00A0\\u000A\\u000D\\u2028\\u2029x; x === "number". Actual: ' + (x));
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
// Copyright 2009 the Sputnik authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
info: Operator "typeof" uses GetValue
|
||||
es5id: 11.4.3_A2_T1
|
||||
description: Either Type(x) is not Reference or GetBase(x) is not null
|
||||
---*/
|
||||
|
||||
//CHECK#1
|
||||
if (typeof 0 !== "number") {
|
||||
$ERROR('#1: typeof 0 === "number". Actual: ' + (typeof 0));
|
||||
}
|
||||
|
||||
//CHECK#2
|
||||
var x = 0;
|
||||
if (typeof x !== "number") {
|
||||
$ERROR('#2: typeof x === "number". Actual: ' + (typeof x));
|
||||
}
|
||||
|
||||
//CHECK#3
|
||||
var x = new Object();
|
||||
if (typeof x !== "object") {
|
||||
$ERROR('#3: var x = new Object(); typeof x === "object". Actual: ' + (typeof x));
|
||||
}
|
|
@ -1,18 +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 null is "object"
|
||||
es5id: 11.4.3_A3.2
|
||||
description: typeof null === "object"
|
||||
---*/
|
||||
|
||||
//CHECK#1
|
||||
if (typeof null !== "object") {
|
||||
$ERROR('#1: typeof null === "object". Actual: ' + (typeof null));
|
||||
}
|
||||
|
||||
//CHECK#2
|
||||
if (typeof RegExp("0").exec("1") !== "object") {
|
||||
$ERROR('#2: typeof RegExp("0").exec("1") === "object". Actual: ' + (typeof RegExp("0").exec("1")));
|
||||
}
|
|
@ -1,23 +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 boolean is "boolean"
|
||||
es5id: 11.4.3_A3.3
|
||||
description: typeof (boolean value) === "boolean"
|
||||
---*/
|
||||
|
||||
//CHECK#1
|
||||
if (typeof true !== "boolean") {
|
||||
$ERROR('#1: typeof true === "boolean". Actual: ' + (typeof true));
|
||||
}
|
||||
|
||||
//CHECK#2
|
||||
if (typeof false !== "boolean") {
|
||||
$ERROR('#2: typeof false === "boolean". Actual: ' + (typeof false));
|
||||
}
|
||||
|
||||
//CHECK#3
|
||||
if (typeof !-1 !== "boolean") {
|
||||
$ERROR('#3: typeof !-1 === "boolean". Actual: ' + (typeof !-1));
|
||||
}
|
|
@ -1,33 +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 appying "typeof" operator to number is "number"
|
||||
es5id: 11.4.3_A3.4
|
||||
description: typeof (number value) === "number"
|
||||
---*/
|
||||
|
||||
//CHECK#1
|
||||
if (typeof 1 !== "number") {
|
||||
$ERROR('#1: typeof 1 === "number". Actual: ' + (typeof 1));
|
||||
}
|
||||
|
||||
//CHECK#2
|
||||
if (typeof Number.NaN !== "number") {
|
||||
$ERROR('#2: typeof NaN === "number". Actual: ' + (typeof NaN));
|
||||
}
|
||||
|
||||
//CHECK#3
|
||||
if (typeof Number.POSITIVE_INFINITY !== "number") {
|
||||
$ERROR('#3: typeof Infinity === "number". Actual: ' + (typeof Infinity));
|
||||
}
|
||||
|
||||
//CHECK#4
|
||||
if (typeof Number.NEGATIVE_INFINITY !== "number") {
|
||||
$ERROR('#4: typeof -Infinity === "number". Actual: ' + (typeof -Infinity));
|
||||
}
|
||||
|
||||
//CHECK#5
|
||||
if (typeof Math.PI !== "number") {
|
||||
$ERROR('#5: typeof Math.PI === "number". Actual: ' + (typeof Math.PI));
|
||||
}
|
|
@ -1,38 +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 appying "typeof" operator to string is "string"
|
||||
es5id: 11.4.3_A3.5
|
||||
description: typeof (string value) === "string"
|
||||
---*/
|
||||
|
||||
//CHECK#1
|
||||
if (typeof "1" !== "string") {
|
||||
$ERROR('#1: typeof "1" === "string". Actual: ' + (typeof "1"));
|
||||
}
|
||||
|
||||
//CHECK#2
|
||||
if (typeof "NaN" !== "string") {
|
||||
$ERROR('#2: typeof "NaN" === "string". Actual: ' + (typeof "NaN"));
|
||||
}
|
||||
|
||||
//CHECK#3
|
||||
if (typeof "Infinity" !== "string") {
|
||||
$ERROR('#3: typeof "Infinity" === "string". Actual: ' + (typeof "Infinity"));
|
||||
}
|
||||
|
||||
//CHECK#4
|
||||
if (typeof "" !== "string") {
|
||||
$ERROR('#4: typeof "" === "string". Actual: ' + (typeof ""));
|
||||
}
|
||||
|
||||
//CHECK#5
|
||||
if (typeof "true" !== "string") {
|
||||
$ERROR('#5: typeof "true" === "string". Actual: ' + (typeof "true"));
|
||||
}
|
||||
|
||||
//CHECK#6
|
||||
if (typeof Date() !== "string") {
|
||||
$ERROR('#6: typeof Date() === "string". Actual: ' + (typeof Date()));
|
||||
}
|
|
@ -1,73 +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
|
||||
description: typeof (object without [[Call]]) === "object"
|
||||
---*/
|
||||
|
||||
//CHECK#1
|
||||
if (typeof this !== "object") {
|
||||
$ERROR('#1: typeof this === "object". Actual: ' + (typeof this));
|
||||
}
|
||||
|
||||
//CHECK#2
|
||||
if (typeof new Object() !== "object") {
|
||||
$ERROR('#2: typeof new Object() === "object". Actual: ' + (typeof new Object()));
|
||||
}
|
||||
|
||||
//CHECK#3
|
||||
if (typeof new Array(1,2,3) !== "object") {
|
||||
$ERROR('#3: typeof new Array(1,2,3) === "object". Actual: ' + (typeof new Array(1,2,3)));
|
||||
}
|
||||
|
||||
//CHECK#4
|
||||
if (typeof Array(1,2,3) !== "object") {
|
||||
$ERROR('#4: typeof Array(1,2,3) === "object". Actual: ' + (typeof Array(1,2,3)));
|
||||
}
|
||||
|
||||
//CHECK#5
|
||||
if (typeof new String("x") !== "object") {
|
||||
$ERROR('#5: typeof new String("x") === "object". Actual: ' + (typeof new String("x")));
|
||||
}
|
||||
|
||||
//CHECK#6
|
||||
if (typeof new Boolean(true) !== "object") {
|
||||
$ERROR('#6: typeof new Boolean(true) === "object". Actual: ' + (typeof new Boolean(true)));
|
||||
}
|
||||
|
||||
//CHECK#7
|
||||
if (typeof new Number(1) !== "object") {
|
||||
$ERROR('#7: typeof new Number(1) === "object". Actual: ' + (typeof new Number(1)));
|
||||
}
|
||||
|
||||
//CHECK#8
|
||||
//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.
|
||||
if (typeof Math !== "object") {
|
||||
$ERROR('#8: typeof Math === "object". Actual: ' + (typeof Math));
|
||||
}
|
||||
|
||||
//CHECK#9
|
||||
if (typeof new Date() !== "object") {
|
||||
$ERROR('#9: typeof new Date() === "object". Actual: ' + (typeof new Date()));
|
||||
}
|
||||
|
||||
//CHECK#10
|
||||
if (typeof new Error() !== "object") {
|
||||
$ERROR('#10: typeof new Error() === "object". Actual: ' + (typeof new Error()));
|
||||
}
|
||||
|
||||
//CHECK#11
|
||||
if (typeof new RegExp() !== "object") {
|
||||
$ERROR('#11: typeof new RegExp() === "object". Actual: ' + (typeof new RegExp()));
|
||||
}
|
||||
|
||||
//CHECK#12
|
||||
if (typeof RegExp() !== "object") {
|
||||
$ERROR('#12: typeof RegExp() === "object". Actual: ' + (typeof RegExp()));
|
||||
}
|
|
@ -1,55 +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
|
||||
implements [[Call]] is "function"
|
||||
es5id: 11.4.3_A3.7
|
||||
description: typeof (object with [[Call]]) === "function"
|
||||
---*/
|
||||
|
||||
//CHECK#1
|
||||
if (typeof new Function() !== "function") {
|
||||
$ERROR('#1: typeof new Function() === "function". Actual: ' + (typeof new Function()));
|
||||
}
|
||||
|
||||
//CHECK#2
|
||||
if (typeof Function() !== "function") {
|
||||
$ERROR('#2: typeof Function() === "function". Actual: ' + (typeof Function()));
|
||||
}
|
||||
|
||||
//CHECK#3
|
||||
if (typeof Object !== "function") {
|
||||
$ERROR('#3: typeof Object === "function". Actual: ' + (typeof Object));
|
||||
}
|
||||
|
||||
//CHECK#4
|
||||
if (typeof String !== "function") {
|
||||
$ERROR('#4: typeof String === "function". Actual: ' + (typeof String));
|
||||
}
|
||||
|
||||
//CHECK5
|
||||
if (typeof Boolean !== "function") {
|
||||
$ERROR('#5: typeof Boolean === "function". Actual: ' + (typeof Boolean));
|
||||
}
|
||||
|
||||
//CHECK#6
|
||||
if (typeof Number !== "function") {
|
||||
$ERROR('#6: typeof Number === "function". Actual: ' + (typeof Number));
|
||||
}
|
||||
|
||||
//CHECK#7
|
||||
if (typeof Date !== "function") {
|
||||
$ERROR('#7: typeof Date === "function". Actual: ' + (typeof Date));
|
||||
}
|
||||
|
||||
//CHECK#8
|
||||
if (typeof Error !== "function") {
|
||||
$ERROR('#8: typeof Error === "function". Actual: ' + (typeof Error));
|
||||
}
|
||||
|
||||
//CHECK#9
|
||||
if (typeof RegExp !== "function") {
|
||||
$ERROR('#9: typeof RegExp === "function". Actual: ' + (typeof RegExp));
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
// 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 boolean is "boolean"
|
||||
es5id: 11.4.3_A3.3
|
||||
es6id: 12.5.6.1
|
||||
description: typeof (boolean value) === "boolean"
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
typeof true,
|
||||
"boolean",
|
||||
'#1: typeof true === "boolean". Actual: ' + (typeof true)
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
typeof false,
|
||||
"boolean",
|
||||
'#2: typeof false === "boolean". Actual: ' + (typeof false)
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
typeof !-1,
|
||||
"boolean",
|
||||
'#3: typeof !-1 === "boolean". Actual: ' + (typeof !-1)
|
||||
);
|
|
@ -6,13 +6,18 @@ 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
|
||||
---*/
|
||||
|
||||
//CHECK#1
|
||||
if(typeof(Math.exp)!=="function")
|
||||
$ERROR('#1: typeof(Math.exp(10))!=="function" '+typeof(Math.exp()));
|
||||
assert.sameValue(
|
||||
typeof Math.exp,
|
||||
"function",
|
||||
'#1: typeof Math.exp!=="function" '+typeof Math.exp
|
||||
);
|
||||
|
||||
//CHECK#2
|
||||
if(typeof(parseInt)!=="function")
|
||||
$ERROR('#2: typeof(parseInt())!=="function" '+typeof(parseInt()));
|
||||
assert.sameValue(
|
||||
typeof parseInt,
|
||||
"function",
|
||||
'#2: typeof parseInt!=="function" '+typeof parseInt
|
||||
);
|
|
@ -0,0 +1,29 @@
|
|||
// Copyright 2009 the Sputnik authors. All rights reserved.
|
||||
// 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
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
typeof 0,
|
||||
"number",
|
||||
'#1: typeof 0 === "number". Actual: ' + (typeof 0)
|
||||
);
|
||||
|
||||
var x = 0;
|
||||
assert.sameValue(
|
||||
typeof x,
|
||||
"number",
|
||||
'#2: typeof x === "number". Actual: ' + (typeof x)
|
||||
);
|
||||
|
||||
var x = new Object();
|
||||
assert.sameValue(
|
||||
typeof x,
|
||||
"object",
|
||||
'#3: var x = new Object(); typeof x === "object". Actual: ' + (typeof x)
|
||||
);
|
|
@ -0,0 +1,65 @@
|
|||
// 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
|
||||
implements [[Call]] is "function"
|
||||
es5id: 11.4.3_A3.7
|
||||
es6id: 12.5.6.1
|
||||
description: typeof (object with [[Call]]) === "function"
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
typeof new Function(),
|
||||
"function",
|
||||
'#1: typeof new Function() === "function". Actual: ' + (typeof new Function())
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
typeof Function(),
|
||||
"function",
|
||||
'#2: typeof Function() === "function". Actual: ' + (typeof Function())
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
typeof Object,
|
||||
"function",
|
||||
'#3: typeof Object === "function". Actual: ' + (typeof Object)
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
typeof String,
|
||||
"function",
|
||||
'#4: typeof String === "function". Actual: ' + (typeof String)
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
typeof Boolean,
|
||||
"function",
|
||||
'#5: typeof Boolean === "function". Actual: ' + (typeof Boolean)
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
typeof Number,
|
||||
"function",
|
||||
'#6: typeof Number === "function". Actual: ' + (typeof Number)
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
typeof Date,
|
||||
"function",
|
||||
'#7: typeof Date === "function". Actual: ' + (typeof Date)
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
typeof Error,
|
||||
"function",
|
||||
'#8: typeof Error === "function". Actual: ' + (typeof Error)
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
typeof RegExp,
|
||||
"function",
|
||||
'#9: typeof RegExp === "function". Actual: ' + (typeof RegExp)
|
||||
);
|
|
@ -0,0 +1,86 @@
|
|||
// 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())
|
||||
);
|
|
@ -0,0 +1,21 @@
|
|||
// 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 null is "object"
|
||||
es5id: 11.4.3_A3.2
|
||||
es6id: 12.5.6.1
|
||||
description: typeof null === "object"
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
typeof null,
|
||||
"object",
|
||||
'#1: typeof null === "object". Actual: ' + (typeof null)
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
typeof RegExp("0").exec("1"),
|
||||
"object",
|
||||
'#2: typeof RegExp("0").exec("1") === "object". Actual: ' + (typeof RegExp("0").exec("1"))
|
||||
);
|
|
@ -0,0 +1,39 @@
|
|||
// Copyright 2009 the Sputnik authors. All rights reserved.
|
||||
// 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"
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
typeof 1,
|
||||
"number",
|
||||
'#1: typeof 1 === "number". Actual: ' + (typeof 1)
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
typeof Number.NaN,
|
||||
"number",
|
||||
'#2: typeof NaN === "number". Actual: ' + (typeof NaN)
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
typeof Number.POSITIVE_INFINITY,
|
||||
"number",
|
||||
'#3: typeof Infinity === "number". Actual: ' + (typeof Infinity)
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
typeof Number.NEGATIVE_INFINITY,
|
||||
"number",
|
||||
'#4: typeof -Infinity === "number". Actual: ' + (typeof -Infinity)
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
typeof Math.PI,
|
||||
"number",
|
||||
'#5: typeof Math.PI === "number". Actual: ' + (typeof Math.PI)
|
||||
);
|
|
@ -0,0 +1,45 @@
|
|||
// Copyright 2009 the Sputnik authors. All rights reserved.
|
||||
// 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"
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
typeof "1",
|
||||
"string",
|
||||
'#1: typeof "1" === "string". Actual: ' + (typeof "1")
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
typeof "NaN",
|
||||
"string",
|
||||
'#2: typeof "NaN" === "string". Actual: ' + (typeof "NaN")
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
typeof "Infinity",
|
||||
"string",
|
||||
'#3: typeof "Infinity" === "string". Actual: ' + (typeof "Infinity")
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
typeof "",
|
||||
"string",
|
||||
'#4: typeof "" === "string". Actual: ' + (typeof "")
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
typeof "true",
|
||||
"string",
|
||||
'#5: typeof "true" === "string". Actual: ' + (typeof "true")
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
typeof Date(),
|
||||
"string",
|
||||
'#6: typeof Date() === "string". Actual: ' + (typeof Date())
|
||||
);
|
|
@ -0,0 +1,77 @@
|
|||
// Copyright 2009 the Sputnik authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
info: >
|
||||
White Space and Line Terminator between "typeof" and UnaryExpression are
|
||||
allowed
|
||||
es5id: 11.4.3_A1
|
||||
es6id: 12.5.6.1
|
||||
description: Checking by using eval
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
eval("var x = 0; typeof\u0009x"),
|
||||
"number",
|
||||
'#1: var x = 0; typeof\\u0009x; x === "number". Actual: ' + (x)
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
eval("var x = 0; typeof\u000Bx"),
|
||||
"number",
|
||||
'#2: var x = 0; typeof\\u000Bx; x === "number". Actual: ' + (x)
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
eval("var x = 0; typeof\u000Cx"),
|
||||
"number",
|
||||
'#3: var x = 0; typeof\\u000Cx; x === "number". Actual: ' + (x)
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
eval("var x = 0; typeof\u0020x"),
|
||||
"number",
|
||||
'#4: var x = 0; typeof\\u0020x; x === "number". Actual: ' + (x)
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
eval("var x = 0; typeof\u00A0x"),
|
||||
"number",
|
||||
'#5: var x = 0; typeof\\u00A0x; x === "number". Actual: ' + (x)
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
eval("var x = 0; typeof\u000Ax"),
|
||||
"number",
|
||||
'#6: var x = 0; typeof\\u000Ax; x === "number". Actual: ' + (x)
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
eval("var x = 0; typeof\u000Dx"),
|
||||
"number",
|
||||
'#7: var x = 0; typeof\\u000Dx; x === "number". Actual: ' + (x)
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
eval("var x = 0; typeof\u2028x"),
|
||||
"number",
|
||||
'#8: var x = 0; typeof\\u2028x; x === "number". Actual: ' + (x)
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
eval("var x = 0; typeof\u2029x"),
|
||||
"number",
|
||||
'#9: var x = 0; typeof\\u2029x; x === "number". Actual: ' + (x)
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
eval("var x = 0; typeof\u0009\u000B\u000C\u0020\u00A0\u000A\u000D\u2028\u2029x"),
|
||||
"number",
|
||||
'#10: var x = 0; typeof\\u0009\\u000B\\u000C\\u0020\\u00A0\\u000A\\u000D\\u2028\\u2029x; x === "number". Actual: ' + (x)
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
eval("typeof(0)"),
|
||||
"number",
|
||||
'applied with grouping operator enclosing operand'
|
||||
);
|
|
@ -4,15 +4,18 @@
|
|||
/*---
|
||||
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"
|
||||
---*/
|
||||
|
||||
//CHECK#1
|
||||
if (typeof undefined !== "undefined") {
|
||||
$ERROR('#1: typeof undefined === "undefined". Actual: ' + (typeof undefined));
|
||||
}
|
||||
assert.sameValue(
|
||||
typeof undefined,
|
||||
"undefined",
|
||||
'#1: typeof undefined === "undefined". Actual: ' + (typeof undefined)
|
||||
);
|
||||
|
||||
//CHECK#2
|
||||
if (typeof void 0 !== "undefined") {
|
||||
$ERROR('#2: typeof void 0 === "undefined". Actual: ' + (typeof void 0));
|
||||
}
|
||||
assert.sameValue(
|
||||
typeof void 0,
|
||||
"undefined",
|
||||
'#2: typeof void 0 === "undefined". Actual: ' + (typeof void 0)
|
||||
);
|
|
@ -4,10 +4,10 @@
|
|||
/*---
|
||||
info: Operator "typeof" uses GetValue
|
||||
es5id: 11.4.3_A2_T2
|
||||
es6id: 12.5.6.1
|
||||
description: If GetBase(x) is null, return "undefined"
|
||||
---*/
|
||||
|
||||
//CHECK#1
|
||||
if (typeof x !== "undefined") {
|
||||
$ERROR('#1: typeof x === "undefined". Actual: ' + (typeof x));
|
||||
}
|
||||
assert.sameValue(
|
||||
typeof x, "undefined", '#1: typeof x === "undefined". Actual: ' + (typeof x)
|
||||
);
|
Loading…
Reference in New Issue