js/src/tests/ecma/Expressions/11.4.3.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial