1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/ecma/Expressions/11.4.3.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,77 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 + 1.10 +/** 1.11 + File Name: typeof_1.js 1.12 + ECMA Section: 11.4.3 typeof operator 1.13 + Description: typeof evaluates unary expressions: 1.14 + undefined "undefined" 1.15 + null "object" 1.16 + Boolean "boolean" 1.17 + Number "number" 1.18 + String "string" 1.19 + Object "object" [native, doesn't implement Call] 1.20 + Object "function" [native, implements [Call]] 1.21 + Object implementation dependent 1.22 + [not sure how to test this] 1.23 + Author: christine@netscape.com 1.24 + Date: june 30, 1997 1.25 + 1.26 +*/ 1.27 + 1.28 +var SECTION = "11.4.3"; 1.29 + 1.30 +var VERSION = "ECMA_1"; 1.31 +startTest(); 1.32 +var TITLE = " The typeof operator"; 1.33 +writeHeaderToLog( SECTION + " "+ TITLE); 1.34 + 1.35 +new TestCase( SECTION, "typeof(void(0))", "undefined", typeof(void(0)) ); 1.36 +new TestCase( SECTION, "typeof(null)", "object", typeof(null) ); 1.37 +new TestCase( SECTION, "typeof(true)", "boolean", typeof(true) ); 1.38 +new TestCase( SECTION, "typeof(false)", "boolean", typeof(false) ); 1.39 +new TestCase( SECTION, "typeof(new Boolean())", "object", typeof(new Boolean()) ); 1.40 +new TestCase( SECTION, "typeof(new Boolean(true))", "object", typeof(new Boolean(true)) ); 1.41 +new TestCase( SECTION, "typeof(Boolean())", "boolean", typeof(Boolean()) ); 1.42 +new TestCase( SECTION, "typeof(Boolean(false))", "boolean", typeof(Boolean(false)) ); 1.43 +new TestCase( SECTION, "typeof(Boolean(true))", "boolean", typeof(Boolean(true)) ); 1.44 +new TestCase( SECTION, "typeof(NaN)", "number", typeof(Number.NaN) ); 1.45 +new TestCase( SECTION, "typeof(Infinity)", "number", typeof(Number.POSITIVE_INFINITY) ); 1.46 +new TestCase( SECTION, "typeof(-Infinity)", "number", typeof(Number.NEGATIVE_INFINITY) ); 1.47 +new TestCase( SECTION, "typeof(Math.PI)", "number", typeof(Math.PI) ); 1.48 +new TestCase( SECTION, "typeof(0)", "number", typeof(0) ); 1.49 +new TestCase( SECTION, "typeof(1)", "number", typeof(1) ); 1.50 +new TestCase( SECTION, "typeof(-1)", "number", typeof(-1) ); 1.51 +new TestCase( SECTION, "typeof('0')", "string", typeof("0") ); 1.52 +new TestCase( SECTION, "typeof(Number())", "number", typeof(Number()) ); 1.53 +new TestCase( SECTION, "typeof(Number(0))", "number", typeof(Number(0)) ); 1.54 +new TestCase( SECTION, "typeof(Number(1))", "number", typeof(Number(1)) ); 1.55 +new TestCase( SECTION, "typeof(Nubmer(-1))", "number", typeof(Number(-1)) ); 1.56 +new TestCase( SECTION, "typeof(new Number())", "object", typeof(new Number()) ); 1.57 +new TestCase( SECTION, "typeof(new Number(0))", "object", typeof(new Number(0)) ); 1.58 +new TestCase( SECTION, "typeof(new Number(1))", "object", typeof(new Number(1)) ); 1.59 + 1.60 +// Math does not implement [[Construct]] or [[Call]] so its type is object. 1.61 + 1.62 +new TestCase( SECTION, "typeof(Math)", "object", typeof(Math) ); 1.63 + 1.64 +new TestCase( SECTION, "typeof(Number.prototype.toString)", "function", typeof(Number.prototype.toString) ); 1.65 + 1.66 +new TestCase( SECTION, "typeof('a string')", "string", typeof("a string") ); 1.67 +new TestCase( SECTION, "typeof('')", "string", typeof("") ); 1.68 +new TestCase( SECTION, "typeof(new Date())", "object", typeof(new Date()) ); 1.69 +new TestCase( SECTION, "typeof(new Array(1,2,3))", "object", typeof(new Array(1,2,3)) ); 1.70 +new TestCase( SECTION, "typeof(new String('string object'))", "object", typeof(new String("string object")) ); 1.71 +new TestCase( SECTION, "typeof(String('string primitive'))", "string", typeof(String("string primitive")) ); 1.72 +new TestCase( SECTION, "typeof(['array', 'of', 'strings'])", "object", typeof(["array", "of", "strings"]) ); 1.73 +new TestCase( SECTION, "typeof(new Function())", "function", typeof( new Function() ) ); 1.74 +new TestCase( SECTION, "typeof(parseInt)", "function", typeof( parseInt ) ); 1.75 +new TestCase( SECTION, "typeof(test)", "function", typeof( test ) ); 1.76 +new TestCase( SECTION, "typeof(String.fromCharCode)", "function", typeof( String.fromCharCode ) ); 1.77 + 1.78 + 1.79 +test(); 1.80 +