]>
git.saurik.com Git - apple/javascriptcore.git/blob - tests/mozilla/ecma_3/Statements/switch-001.js
2 * The contents of this file are subject to the Netscape Public
3 * License Version 1.1 (the "License"); you may not use this file
4 * except in compliance with the License. You may obtain a copy of
5 * the License at http://www.mozilla.org/NPL/
7 * Software distributed under the License is distributed on an "AS IS"
8 * basis, WITHOUT WARRANTY OF ANY KIND, either expressed
9 * or implied. See the License for the specific language governing
10 * rights and limitations under the License.
12 * The Original Code is mozilla.org code.
14 * The Initial Developer of the Original Code is Netscape
15 * Communications Corporation. Portions created by Netscape are
16 * Copyright (C) 1998 Netscape Communications Corporation. All
19 * Contributor(s): pschwartau@netscape.com
22 * SUMMARY: Testing the switch statement
24 * See ECMA3 Section 12.11, "The switch Statement"
26 //-------------------------------------------------------------------------------------------------
29 var summary
= 'Testing the switch statement';
30 var cnMatch
= 'Match';
31 var cnNoMatch
= 'NoMatch';
33 var statusitems
= [ ];
35 var actualvalues
= [ ];
37 var expectedvalues
= [ ];
40 status
= 'Section A of test';
41 actual
= match(17, f(fInverse(17)), f
, fInverse
);
45 status
= 'Section B of test';
46 actual
= match(17, 18, f
, fInverse
);
50 status
= 'Section C of test';
51 actual
= match(1, 1, Math
.exp
, Math
.log
);
55 status
= 'Section D of test';
56 actual
= match(1, 2, Math
.exp
, Math
.log
);
60 status
= 'Section E of test';
61 actual
= match(1, 1, Math
.sin
, Math
.cos
);
67 //---------------------------------------------------------------------------------
69 //---------------------------------------------------------------------------------
74 * If F,G are inverse functions and x==y, this should return cnMatch -
76 function match(x
, y
, F
, G
)
91 statusitems
[UBound
] = status
;
92 actualvalues
[UBound
] = actual
;
93 expectedvalues
[UBound
] = expect
;
101 printBugNumber (bug
);
102 printStatus (summary
);
104 for (var i
= 0; i
< UBound
; i
++)
106 reportCompare(expectedvalues
[i
], actualvalues
[i
], statusitems
[i
]);