|
1 // Copyright 2009 the Sputnik authors. All rights reserved. |
|
2 // This code is governed by the BSD license found in the LICENSE file. |
|
3 |
|
4 /** |
|
5 * 1. Evaluate Expression |
|
6 * |
|
7 * @path ch12/12.13/S12.13_A3_T3.js |
|
8 * @description Evaluating number expression |
|
9 */ |
|
10 |
|
11 // CHECK#1 |
|
12 try{ |
|
13 throw 10+3; |
|
14 } |
|
15 catch(e){ |
|
16 if (e!==13) $ERROR('#1: Exception ===13(operaton +). Actual: Exception ==='+ e); |
|
17 } |
|
18 |
|
19 // CHECK#2 |
|
20 var b=10; |
|
21 var a=3; |
|
22 try{ |
|
23 throw a+b; |
|
24 } |
|
25 catch(e){ |
|
26 if (e!==13) $ERROR('#2: Exception ===13(operaton +). Actual: Exception ==='+ e); |
|
27 } |
|
28 |
|
29 // CHECK#3 |
|
30 try{ |
|
31 throw 3.15-1.02; |
|
32 } |
|
33 catch(e){ |
|
34 if (e!==2.13) $ERROR('#3: Exception ===2.13(operaton -). Actual: Exception ==='+ e); |
|
35 } |
|
36 |
|
37 // CHECK#4 |
|
38 try{ |
|
39 throw 2*2; |
|
40 } |
|
41 catch(e){ |
|
42 if (e!==4) $ERROR('#4: Exception ===4(operaton *). Actual: Exception ==='+ e); |
|
43 } |
|
44 |
|
45 // CHECK#5 |
|
46 try{ |
|
47 throw 1+Infinity; |
|
48 } |
|
49 catch(e){ |
|
50 if (e!==+Infinity) $ERROR('#5: Exception ===+Infinity(operaton +). Actual: Exception ==='+ e); |
|
51 } |
|
52 |
|
53 // CHECK#6 |
|
54 try{ |
|
55 throw 1-Infinity; |
|
56 } |
|
57 catch(e){ |
|
58 if (e!==-Infinity) $ERROR('#6: Exception ===-Infinity(operaton -). Actual: Exception ==='+ e); |
|
59 } |
|
60 |
|
61 // CHECK#7 |
|
62 try{ |
|
63 throw 10/5; |
|
64 } |
|
65 catch(e){ |
|
66 if (e!==2) $ERROR('#7: Exception ===2(operaton /). Actual: Exception ==='+ e); |
|
67 } |
|
68 |
|
69 // CHECK#8 |
|
70 try{ |
|
71 throw 8>>2; |
|
72 } |
|
73 catch(e){ |
|
74 if (e!==2) $ERROR('#8: Exception ===2(operaton >>). Actual: Exception ==='+ e); |
|
75 } |
|
76 |
|
77 // CHECK#9 |
|
78 try{ |
|
79 throw 2<<2; |
|
80 } |
|
81 catch(e){ |
|
82 if (e!==8) $ERROR('#9: Exception ===8(operaton <<). Actual: Exception ==='+ e); |
|
83 } |
|
84 |
|
85 // CHECK#10 |
|
86 try{ |
|
87 throw 123%100; |
|
88 } |
|
89 catch(e){ |
|
90 if (e!==23) $ERROR('#10: Exception ===23(operaton %). Actual: Exception ==='+ e); |
|
91 } |
|
92 |