1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/ecma_3/Object/class-002.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,112 @@ 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 [[Class]] property of native constructors. 1.13 + * See ECMA-262 Edition 3 13-Oct-1999, Section 8.6.2 re [[Class]] property. 1.14 + * 1.15 + * Same as class-001.js - but testing the constructors here, not 1.16 + * object instances. Therefore we expect the [[Class]] property to 1.17 + * equal 'Function' in each case. 1.18 + * 1.19 + * The getJSClass() function we use is in a utility file, e.g. "shell.js" 1.20 + */ 1.21 +//----------------------------------------------------------------------------- 1.22 +var i = 0; 1.23 +var UBound = 0; 1.24 +var BUGNUMBER = '(none)'; 1.25 +var summary = 'Testing the internal [[Class]] property of native constructors'; 1.26 +var statprefix = 'Current constructor is: '; 1.27 +var status = ''; var statusList = [ ]; 1.28 +var actual = ''; var actualvalue = [ ]; 1.29 +var expect= ''; var expectedvalue = [ ]; 1.30 + 1.31 +/* 1.32 + * We set the expect variable each time only for readability. 1.33 + * We expect 'Function' every time; see discussion above - 1.34 + */ 1.35 +status = 'Object'; 1.36 +actual = getJSClass(Object); 1.37 +expect = 'Function'; 1.38 +addThis(); 1.39 + 1.40 +status = 'Function'; 1.41 +actual = getJSClass(Function); 1.42 +expect = 'Function'; 1.43 +addThis(); 1.44 + 1.45 +status = 'Array'; 1.46 +actual = getJSClass(Array); 1.47 +expect = 'Function'; 1.48 +addThis(); 1.49 + 1.50 +status = 'String'; 1.51 +actual = getJSClass(String); 1.52 +expect = 'Function'; 1.53 +addThis(); 1.54 + 1.55 +status = 'Boolean'; 1.56 +actual = getJSClass(Boolean); 1.57 +expect = 'Function'; 1.58 +addThis(); 1.59 + 1.60 +status = 'Number'; 1.61 +actual = getJSClass(Number); 1.62 +expect = 'Function'; 1.63 +addThis(); 1.64 + 1.65 +status = 'Date'; 1.66 +actual = getJSClass(Date); 1.67 +expect = 'Function'; 1.68 +addThis(); 1.69 + 1.70 +status = 'RegExp'; 1.71 +actual = getJSClass(RegExp); 1.72 +expect = 'Function'; 1.73 +addThis(); 1.74 + 1.75 +status = 'Error'; 1.76 +actual = getJSClass(Error); 1.77 +expect = 'Function'; 1.78 +addThis(); 1.79 + 1.80 + 1.81 + 1.82 +//--------------------------------------------------------------------------------- 1.83 +test(); 1.84 +//--------------------------------------------------------------------------------- 1.85 + 1.86 + 1.87 + 1.88 +function addThis() 1.89 +{ 1.90 + statusList[UBound] = status; 1.91 + actualvalue[UBound] = actual; 1.92 + expectedvalue[UBound] = expect; 1.93 + UBound++; 1.94 +} 1.95 + 1.96 + 1.97 +function test() 1.98 +{ 1.99 + enterFunc ('test'); 1.100 + printBugNumber(BUGNUMBER); 1.101 + printStatus (summary); 1.102 + 1.103 + for (i = 0; i < UBound; i++) 1.104 + { 1.105 + reportCompare(expectedvalue[i], actualvalue[i], getStatus(i)); 1.106 + } 1.107 + 1.108 + exitFunc ('test'); 1.109 +} 1.110 + 1.111 + 1.112 +function getStatus(i) 1.113 +{ 1.114 + return statprefix + statusList[i]; 1.115 +}