Debian Codegraph @

rhino/testsrc/tests/ecma/Expressions/11.4.3.js

raw symbols SCIP
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/. */
5
6 gTestfile = '11.4.3.js';
7
8 /**
9 File Name: typeof_1.js
10 ECMA Section: 11.4.3 typeof operator
11 Description: typeof evaluates unary expressions:
12 undefined "undefined"
13 null "object"
14 Boolean "boolean"
15 Number "number"
16 String "string"
17 Object "object" [native, doesn't implement Call]
18 Object "function" [native, implements [Call]]
19 Object implementation dependent
20 [not sure how to test this]
21 Author: [email protected]
22 Date: june 30, 1997
23
24 */
25
26 var SECTION = "11.4.3";
27
28 var VERSION = "ECMA_1";
29 startTest();
30 var TITLE = " The typeof operator";
31 writeHeaderToLog( SECTION + " "+ TITLE);
32
33 new TestCase( SECTION, "typeof(void(0))", "undefined", typeof(void(0)) );
34 new TestCase( SECTION, "typeof(null)", "object", typeof(null) );
35 new TestCase( SECTION, "typeof(true)", "boolean", typeof(true) );
36 new TestCase( SECTION, "typeof(false)", "boolean", typeof(false) );
37 new TestCase( SECTION, "typeof(new Boolean())", "object", typeof(new Boolean()) );
38 new TestCase( SECTION, "typeof(new Boolean(true))", "object", typeof(new Boolean(true)) );
39 new TestCase( SECTION, "typeof(Boolean())", "boolean", typeof(Boolean()) );
40 new TestCase( SECTION, "typeof(Boolean(false))", "boolean", typeof(Boolean(false)) );
41 new TestCase( SECTION, "typeof(Boolean(true))", "boolean", typeof(Boolean(true)) );
42 new TestCase( SECTION, "typeof(NaN)", "number", typeof(Number.NaN) );
43 new TestCase( SECTION, "typeof(Infinity)", "number", typeof(Number.POSITIVE_INFINITY) );
44 new TestCase( SECTION, "typeof(-Infinity)", "number", typeof(Number.NEGATIVE_INFINITY) );
45 new TestCase( SECTION, "typeof(Math.PI)", "number", typeof(Math.PI) );
46 new TestCase( SECTION, "typeof(0)", "number", typeof(0) );
47 new TestCase( SECTION, "typeof(1)", "number", typeof(1) );
48 new TestCase( SECTION, "typeof(-1)", "number", typeof(-1) );
49 new TestCase( SECTION, "typeof('0')", "string", typeof("0") );
50 new TestCase( SECTION, "typeof(Number())", "number", typeof(Number()) );
51 new TestCase( SECTION, "typeof(Number(0))", "number", typeof(Number(0)) );
52 new TestCase( SECTION, "typeof(Number(1))", "number", typeof(Number(1)) );
53 new TestCase( SECTION, "typeof(Nubmer(-1))", "number", typeof(Number(-1)) );
54 new TestCase( SECTION, "typeof(new Number())", "object", typeof(new Number()) );
55 new TestCase( SECTION, "typeof(new Number(0))", "object", typeof(new Number(0)) );
56 new TestCase( SECTION, "typeof(new Number(1))", "object", typeof(new Number(1)) );
57
58 // Math does not implement [[Construct]] or [[Call]] so its type is object.
59
60 new TestCase( SECTION, "typeof(Math)", "object", typeof(Math) );
61
62 new TestCase( SECTION, "typeof(Number.prototype.toString)", "function", typeof(Number.prototype.toString) );
63
64 new TestCase( SECTION, "typeof('a string')", "string", typeof("a string") );
65 new TestCase( SECTION, "typeof('')", "string", typeof("") );
66 new TestCase( SECTION, "typeof(new Date())", "object", typeof(new Date()) );
67 new TestCase( SECTION, "typeof(new Array(1,2,3))", "object", typeof(new Array(1,2,3)) );
68 new TestCase( SECTION, "typeof(new String('string object'))", "object", typeof(new String("string object")) );
69 new TestCase( SECTION, "typeof(String('string primitive'))", "string", typeof(String("string primitive")) );
70 new TestCase( SECTION, "typeof(['array', 'of', 'strings'])", "object", typeof(["array", "of", "strings"]) );
71 new TestCase( SECTION, "typeof(new Function())", "function", typeof( new Function() ) );
72 new TestCase( SECTION, "typeof(parseInt)", "function", typeof( parseInt ) );
73 new TestCase( SECTION, "typeof(test)", "function", typeof( test ) );
74 new TestCase( SECTION, "typeof(String.fromCharCode)", "function", typeof( String.fromCharCode ) );
75
76
77 test();
78