OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | |
2 // for details. All rights reserved. Use of this source code is governed by a | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 // VMOptions= | |
5 // VMOptions=--compile_all | |
6 | |
7 // Exercises language constructs that require compile time constants | |
8 | |
9 // Initialize with different literal types | |
10 final b = true; | |
11 final s = "apple"; | |
12 final i = 1; | |
13 final d = 3.3; | |
14 final h = 0xf; | |
15 final n = null; | |
16 final aList = const[1, 2, 3]; // array literal | |
17 final aMap = const { "1": "one", "2": "banana" }; // map literal | |
18 | |
19 final INT_LIT = 5; | |
20 final INT_LIT_REF = INT_LIT; | |
21 final DOUBLE_LIT = 1.5; | |
22 final BOOL_LIT = true; | |
23 final STRING_LIT = "Hello"; | |
24 | |
25 final BOP1_0 = INT_LIT + 1; | |
26 final BOP1_1 = 1 + INT_LIT; | |
27 final BOP1_2 = INT_LIT - 1; | |
28 final BOP1_3 = 1 - INT_LIT; | |
29 final BOP1_4 = INT_LIT * 1; | |
30 final BOP1_5 = 1 * INT_LIT; | |
31 final BOP1_6 = INT_LIT / 1; | |
32 final BOP1_7 = 1 / INT_LIT; | |
33 final BOP2_0 = DOUBLE_LIT + 1.5; | |
34 final BOP2_1 = 1.5 + DOUBLE_LIT; | |
35 final BOP2_2 = DOUBLE_LIT - 1.5; | |
36 final BOP2_3 = 1.5 - DOUBLE_LIT; | |
37 final BOP2_4 = DOUBLE_LIT * 1.5; | |
38 final BOP2_5 = 1.5 * DOUBLE_LIT; | |
39 final BOP2_6 = DOUBLE_LIT / 1.5; | |
40 final BOP2_7 = 1.5 / DOUBLE_LIT; | |
41 final BOP3_0 = 2 < INT_LIT; | |
42 final BOP3_1 = INT_LIT < 2; | |
43 final BOP3_2 = 2 > INT_LIT; | |
44 final BOP3_3 = INT_LIT > 2; | |
45 final BOP3_4 = 2 < DOUBLE_LIT; | |
46 final BOP3_5 = DOUBLE_LIT < 2; | |
47 final BOP3_6 = 2 > DOUBLE_LIT; | |
48 final BOP3_7 = DOUBLE_LIT > 2; | |
49 final BOP3_8 = 2 <= INT_LIT; | |
50 final BOP3_9 = INT_LIT <= 2; | |
51 final BOP3_10 = 2 >= INT_LIT; | |
52 final BOP3_11 = INT_LIT >= 2; | |
53 final BOP3_12 = 2.0 <= DOUBLE_LIT; | |
54 final BOP3_13 = DOUBLE_LIT <= 2.0; | |
55 final BOP3_14 = 2.0 >= DOUBLE_LIT; | |
56 final BOP3_15 = DOUBLE_LIT >= 2; | |
57 final BOP4_0 = 5 % INT_LIT; | |
58 final BOP4_1 = INT_LIT % 5; | |
59 final BOP4_2 = 5.0 % DOUBLE_LIT; | |
60 final BOP4_3 = DOUBLE_LIT % 5.0; | |
61 final BOP5_0 = 0x80 & 0x04; | |
62 final BOP5_1 = 0x80 | 0x04; | |
63 final BOP5_2 = 0x80 << 0x04; | |
64 final BOP5_3 = 0x80 >> 0x04; | |
65 final BOP5_4 = 0x80 ~/ 0x04; | |
66 final BOP5_5 = 0x80 ^ 0x04; | |
67 final BOP6 = BOOL_LIT && true; | |
68 final BOP7 = false || BOOL_LIT; | |
69 final BOP8 = STRING_LIT == "World!"; | |
70 final BOP9 = "Hello" != STRING_LIT; | |
71 final BOP10 = INT_LIT === INT_LIT_REF; | |
72 final BOP11 = BOOL_LIT !== true; | |
73 | |
74 // Multiple binary expressions | |
75 final BOP20 = 1 * INT_LIT / 3 + INT_LIT + 9; | |
76 | |
77 // Parenthised expressions | |
78 final BOP30 = ( 1 > 2 ); | |
79 final BOP31 = (1 * 2) + 3; | |
80 final BOP32= 3 + (1 * 2); | |
81 | |
82 // Unary expressions | |
83 final UOP1_0 = !BOOL_LIT; | |
84 final UOP1_1 = BOOL_LIT || !true; | |
85 final UOP1_2 = !BOOL_LIT || true; | |
86 final UOP1_3 = !(BOOL_LIT && true); | |
87 final UOP2_0 = ~0xf0; | |
88 final UOP2_1 = ~INT_LIT; | |
89 final UOP2_2 = ~INT_LIT & 123; | |
90 final UOP2_3 = ~(INT_LIT | 0xff); | |
91 final UOP3_0 = -0xf0; | |
92 final UOP3_1 = -INT_LIT; | |
93 final UOP3_2 = -INT_LIT + 123; | |
94 final UOP3_3 = -(INT_LIT * 0xff); | |
95 final UOP3_4 = -0xf0; | |
96 final UOP3_5 = -DOUBLE_LIT; | |
97 final UOP3_6 = -DOUBLE_LIT + 123; | |
98 final UOP3_7 = -(DOUBLE_LIT * 0xff); | |
99 | |
100 class A { | |
101 const A(); | |
102 static final a = const A(); // Assignment from Constant constructor OK | |
103 } | |
104 | |
105 main () { | |
106 } | |
OLD | NEW |