1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/ecma_3/Object/class-001.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,122 @@ 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 + * Date: 14 Mar 2001 1.11 + * 1.12 + * SUMMARY: Testing the internal [[Class]] property of objects 1.13 + * See ECMA-262 Edition 3 13-Oct-1999, Section 8.6.2 1.14 + * 1.15 + * The getJSClass() function we use is in a utility file, e.g. "shell.js". 1.16 + */ 1.17 +//----------------------------------------------------------------------------- 1.18 +var i = 0; 1.19 +var UBound = 0; 1.20 +var BUGNUMBER = '(none)'; 1.21 +var summary = 'Testing the internal [[Class]] property of objects'; 1.22 +var statprefix = 'Current object is: '; 1.23 +var status = ''; var statusList = [ ]; 1.24 +var actual = ''; var actualvalue = [ ]; 1.25 +var expect= ''; var expectedvalue = [ ]; 1.26 + 1.27 + 1.28 +status = 'the global object'; 1.29 +actual = getJSClass(this); 1.30 +expect = GLOBAL; 1.31 +if (expect == 'Window' && actual == 'XPCCrossOriginWrapper') 1.32 +{ 1.33 + print('Skipping global object due to XPCCrossOriginWrapper. See bug 390946'); 1.34 +} 1.35 +else 1.36 +{ 1.37 + addThis(); 1.38 +} 1.39 + 1.40 +status = 'new Object()'; 1.41 +actual = getJSClass(new Object()); 1.42 +expect = 'Object'; 1.43 +addThis(); 1.44 + 1.45 +status = 'new Function()'; 1.46 +actual = getJSClass(new Function()); 1.47 +expect = 'Function'; 1.48 +addThis(); 1.49 + 1.50 +status = 'new Array()'; 1.51 +actual = getJSClass(new Array()); 1.52 +expect = 'Array'; 1.53 +addThis(); 1.54 + 1.55 +status = 'new String()'; 1.56 +actual = getJSClass(new String()); 1.57 +expect = 'String'; 1.58 +addThis(); 1.59 + 1.60 +status = 'new Boolean()'; 1.61 +actual = getJSClass(new Boolean()); 1.62 +expect = 'Boolean'; 1.63 +addThis(); 1.64 + 1.65 +status = 'new Number()'; 1.66 +actual = getJSClass(new Number()); 1.67 +expect = 'Number'; 1.68 +addThis(); 1.69 + 1.70 +status = 'Math'; 1.71 +actual = getJSClass(Math); // can't use 'new' with the Math object (EMCA3, 15.8) 1.72 +expect = 'Math'; 1.73 +addThis(); 1.74 + 1.75 +status = 'new Date()'; 1.76 +actual = getJSClass(new Date()); 1.77 +expect = 'Date'; 1.78 +addThis(); 1.79 + 1.80 +status = 'new RegExp()'; 1.81 +actual = getJSClass(new RegExp()); 1.82 +expect = 'RegExp'; 1.83 +addThis(); 1.84 + 1.85 +status = 'new Error()'; 1.86 +actual = getJSClass(new Error()); 1.87 +expect = 'Error'; 1.88 +addThis(); 1.89 + 1.90 + 1.91 + 1.92 +//--------------------------------------------------------------------------------- 1.93 +test(); 1.94 +//--------------------------------------------------------------------------------- 1.95 + 1.96 + 1.97 + 1.98 +function addThis() 1.99 +{ 1.100 + statusList[UBound] = status; 1.101 + actualvalue[UBound] = actual; 1.102 + expectedvalue[UBound] = expect; 1.103 + UBound++; 1.104 +} 1.105 + 1.106 + 1.107 +function test() 1.108 +{ 1.109 + enterFunc ('test'); 1.110 + printBugNumber(BUGNUMBER); 1.111 + printStatus (summary); 1.112 + 1.113 + for (i = 0; i < UBound; i++) 1.114 + { 1.115 + reportCompare(expectedvalue[i], actualvalue[i], getStatus(i)); 1.116 + } 1.117 + 1.118 + exitFunc ('test'); 1.119 +} 1.120 + 1.121 + 1.122 +function getStatus(i) 1.123 +{ 1.124 + return statprefix + statusList[i]; 1.125 +}