Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 /**
8 File Name: typeof_1.js
9 ECMA Section: 11.4.3 typeof operator
10 Description: typeof evaluates unary expressions:
11 undefined "undefined"
12 null "object"
13 Boolean "boolean"
14 Number "number"
15 String "string"
16 Object "object" [native, doesn't implement Call]
17 Object "function" [native, implements [Call]]
18 Object implementation dependent
19 [not sure how to test this]
20 Author: christine@netscape.com
21 Date: june 30, 1997
23 */
25 var SECTION = "11.4.3";
27 var VERSION = "ECMA_1";
28 startTest();
29 var TITLE = " The typeof operator";
30 writeHeaderToLog( SECTION + " "+ TITLE);
32 new TestCase( SECTION, "typeof(void(0))", "undefined", typeof(void(0)) );
33 new TestCase( SECTION, "typeof(null)", "object", typeof(null) );
34 new TestCase( SECTION, "typeof(true)", "boolean", typeof(true) );
35 new TestCase( SECTION, "typeof(false)", "boolean", typeof(false) );
36 new TestCase( SECTION, "typeof(new Boolean())", "object", typeof(new Boolean()) );
37 new TestCase( SECTION, "typeof(new Boolean(true))", "object", typeof(new Boolean(true)) );
38 new TestCase( SECTION, "typeof(Boolean())", "boolean", typeof(Boolean()) );
39 new TestCase( SECTION, "typeof(Boolean(false))", "boolean", typeof(Boolean(false)) );
40 new TestCase( SECTION, "typeof(Boolean(true))", "boolean", typeof(Boolean(true)) );
41 new TestCase( SECTION, "typeof(NaN)", "number", typeof(Number.NaN) );
42 new TestCase( SECTION, "typeof(Infinity)", "number", typeof(Number.POSITIVE_INFINITY) );
43 new TestCase( SECTION, "typeof(-Infinity)", "number", typeof(Number.NEGATIVE_INFINITY) );
44 new TestCase( SECTION, "typeof(Math.PI)", "number", typeof(Math.PI) );
45 new TestCase( SECTION, "typeof(0)", "number", typeof(0) );
46 new TestCase( SECTION, "typeof(1)", "number", typeof(1) );
47 new TestCase( SECTION, "typeof(-1)", "number", typeof(-1) );
48 new TestCase( SECTION, "typeof('0')", "string", typeof("0") );
49 new TestCase( SECTION, "typeof(Number())", "number", typeof(Number()) );
50 new TestCase( SECTION, "typeof(Number(0))", "number", typeof(Number(0)) );
51 new TestCase( SECTION, "typeof(Number(1))", "number", typeof(Number(1)) );
52 new TestCase( SECTION, "typeof(Nubmer(-1))", "number", typeof(Number(-1)) );
53 new TestCase( SECTION, "typeof(new Number())", "object", typeof(new Number()) );
54 new TestCase( SECTION, "typeof(new Number(0))", "object", typeof(new Number(0)) );
55 new TestCase( SECTION, "typeof(new Number(1))", "object", typeof(new Number(1)) );
57 // Math does not implement [[Construct]] or [[Call]] so its type is object.
59 new TestCase( SECTION, "typeof(Math)", "object", typeof(Math) );
61 new TestCase( SECTION, "typeof(Number.prototype.toString)", "function", typeof(Number.prototype.toString) );
63 new TestCase( SECTION, "typeof('a string')", "string", typeof("a string") );
64 new TestCase( SECTION, "typeof('')", "string", typeof("") );
65 new TestCase( SECTION, "typeof(new Date())", "object", typeof(new Date()) );
66 new TestCase( SECTION, "typeof(new Array(1,2,3))", "object", typeof(new Array(1,2,3)) );
67 new TestCase( SECTION, "typeof(new String('string object'))", "object", typeof(new String("string object")) );
68 new TestCase( SECTION, "typeof(String('string primitive'))", "string", typeof(String("string primitive")) );
69 new TestCase( SECTION, "typeof(['array', 'of', 'strings'])", "object", typeof(["array", "of", "strings"]) );
70 new TestCase( SECTION, "typeof(new Function())", "function", typeof( new Function() ) );
71 new TestCase( SECTION, "typeof(parseInt)", "function", typeof( parseInt ) );
72 new TestCase( SECTION, "typeof(test)", "function", typeof( test ) );
73 new TestCase( SECTION, "typeof(String.fromCharCode)", "function", typeof( String.fromCharCode ) );
76 test();