OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 // VMOptions=--assert_initializer | 5 // VMOptions=--assert_initializer |
6 import "package:expect/expect.dart"; | 6 import "package:expect/expect.dart"; |
7 | 7 |
8 bool assertsEnabled = false; | 8 bool assertsEnabled = false; |
9 | 9 |
10 main() { | 10 main() { |
(...skipping 14 matching lines...) Expand all Loading... |
25 const c09 = const AssertCompare.constLast(1, 2); | 25 const c09 = const AssertCompare.constLast(1, 2); |
26 const c10 = const AssertCompare.constMiddle(1, 2); | 26 const c10 = const AssertCompare.constMiddle(1, 2); |
27 const c11 = const AssertCompare.constMulti(1, 2); | 27 const c11 = const AssertCompare.constMulti(1, 2); |
28 const c12 = const AssertCompare.constFirstSuper(1, 2); | 28 const c12 = const AssertCompare.constFirstSuper(1, 2); |
29 const c13 = const AssertCompare.constLastSuper(1, 2); | 29 const c13 = const AssertCompare.constLastSuper(1, 2); |
30 const c14 = const AssertCompare.constMiddleSuper(1, 2); | 30 const c14 = const AssertCompare.constMiddleSuper(1, 2); |
31 const c15 = const AssertCompare.constMultiSuper(1, 2); | 31 const c15 = const AssertCompare.constMultiSuper(1, 2); |
32 | 32 |
33 // Failing const expressions | 33 // Failing const expressions |
34 | 34 |
35 const c = const AssertArgument.constFirst(false, 0, 1); // //# 01: compi
le-time error | 35 const c = const AssertArgument.constFirst(false, 0, 1); // //# 01: check
ed mode compile-time error |
36 const c = const AssertArgument.constLast(false, 0, 1); // //# 02: compi
le-time error | 36 const c = const AssertArgument.constLast(false, 0, 1); // //# 02: check
ed mode compile-time error |
37 const c = const AssertArgument.constMiddle(false, 0, 1); // //# 03: compi
le-time error | 37 const c = const AssertArgument.constMiddle(false, 0, 1); // //# 03: check
ed mode compile-time error |
38 const c = const AssertArgument.constMulti(false, 0, 1); // //# 04: compi
le-time error | 38 const c = const AssertArgument.constMulti(false, 0, 1); // //# 04: check
ed mode compile-time error |
39 const c = const AssertArgument.constFirstSuper(false, 0, 1); // //# 05: compi
le-time error | 39 const c = const AssertArgument.constFirstSuper(false, 0, 1); // //# 05: check
ed mode compile-time error |
40 const c = const AssertArgument.constLastSuper(false, 0, 1); // //# 06: compi
le-time error | 40 const c = const AssertArgument.constLastSuper(false, 0, 1); // //# 06: check
ed mode compile-time error |
41 const c = const AssertArgument.constMiddleSuper(false, 0, 1); // //# 07: compi
le-time error | 41 const c = const AssertArgument.constMiddleSuper(false, 0, 1); // //# 07: check
ed mode compile-time error |
42 const c = const AssertArgument.constMultiSuper(false, 0, 1); // //# 08: compi
le-time error | 42 const c = const AssertArgument.constMultiSuper(false, 0, 1); // //# 08: check
ed mode compile-time error |
43 | 43 |
44 const c = const AssertArgument.constFirst("str", 0, 1); // //# 11: compi
le-time error | 44 const c = const AssertArgument.constFirst("str", 0, 1); // //# 11: check
ed mode compile-time error |
45 const c = const AssertArgument.constLast("str", 0, 1); // //# 12: compi
le-time error | 45 const c = const AssertArgument.constLast("str", 0, 1); // //# 12: check
ed mode compile-time error |
46 const c = const AssertArgument.constMiddle("str", 0, 1); // //# 13: compi
le-time error | 46 const c = const AssertArgument.constMiddle("str", 0, 1); // //# 13: check
ed mode compile-time error |
47 const c = const AssertArgument.constMulti("str", 0, 1); // //# 14: compi
le-time error | 47 const c = const AssertArgument.constMulti("str", 0, 1); // //# 14: check
ed mode compile-time error |
48 const c = const AssertArgument.constFirstSuper("str", 0, 1); // //# 15: compi
le-time error | 48 const c = const AssertArgument.constFirstSuper("str", 0, 1); // //# 15: check
ed mode compile-time error |
49 const c = const AssertArgument.constLastSuper("str", 0, 1); // //# 16: compi
le-time error | 49 const c = const AssertArgument.constLastSuper("str", 0, 1); // //# 16: check
ed mode compile-time error |
50 const c = const AssertArgument.constMiddleSuper("str", 0, 1); // //# 17: compi
le-time error | 50 const c = const AssertArgument.constMiddleSuper("str", 0, 1); // //# 17: check
ed mode compile-time error |
51 const c = const AssertArgument.constMultiSuper("str", 0, 1); // //# 18: compi
le-time error | 51 const c = const AssertArgument.constMultiSuper("str", 0, 1); // //# 18: check
ed mode compile-time error |
52 | 52 |
53 const c = const AssertCompare.constFirst(3, 2); // //# 21: compi
le-time error | 53 const c = const AssertCompare.constFirst(3, 2); // //# 21: check
ed mode compile-time error |
54 const c = const AssertCompare.constLast(3, 2); // //# 22: compi
le-time error | 54 const c = const AssertCompare.constLast(3, 2); // //# 22: check
ed mode compile-time error |
55 const c = const AssertCompare.constMiddle(3, 2); // //# 23: compi
le-time error | 55 const c = const AssertCompare.constMiddle(3, 2); // //# 23: check
ed mode compile-time error |
56 const c = const AssertCompare.constMulti(3, 2); // //# 24: compi
le-time error | 56 const c = const AssertCompare.constMulti(3, 2); // //# 24: check
ed mode compile-time error |
57 const c = const AssertCompare.constFirstSuper(3, 2); // //# 25: compi
le-time error | 57 const c = const AssertCompare.constFirstSuper(3, 2); // //# 25: check
ed mode compile-time error |
58 const c = const AssertCompare.constLastSuper(3, 2); // //# 26: compi
le-time error | 58 const c = const AssertCompare.constLastSuper(3, 2); // //# 26: check
ed mode compile-time error |
59 const c = const AssertCompare.constMiddleSuper(3, 2); // //# 27: compi
le-time error | 59 const c = const AssertCompare.constMiddleSuper(3, 2); // //# 27: check
ed mode compile-time error |
60 const c = const AssertCompare.constMultiSuper(3, 2); // //# 28: compi
le-time error | 60 const c = const AssertCompare.constMultiSuper(3, 2); // //# 28: check
ed mode compile-time error |
61 | 61 |
62 // Functions not allowed in asserts in const execution. | 62 // Functions not allowed in asserts in const execution. |
63 const c = const AssertArgument.constFirst(kTrue, 0, 1); // //# 31: compi
le-time error | 63 const c = const AssertArgument.constFirst(kTrue, 0, 1); // //# 31: check
ed mode compile-time error |
64 const c = const AssertArgument.constLast(kTrue, 0, 1); // //# 32: compi
le-time error | 64 const c = const AssertArgument.constLast(kTrue, 0, 1); // //# 32: check
ed mode compile-time error |
65 const c = const AssertArgument.constMiddle(kTrue, 0, 1); // //# 33: compi
le-time error | 65 const c = const AssertArgument.constMiddle(kTrue, 0, 1); // //# 33: check
ed mode compile-time error |
66 const c = const AssertArgument.constMulti(kTrue, 0, 1); // //# 34: compi
le-time error | 66 const c = const AssertArgument.constMulti(kTrue, 0, 1); // //# 34: check
ed mode compile-time error |
67 const c = const AssertArgument.constFirstSuper(kTrue, 0, 1); // //# 35: compi
le-time error | 67 const c = const AssertArgument.constFirstSuper(kTrue, 0, 1); // //# 35: check
ed mode compile-time error |
68 const c = const AssertArgument.constLastSuper(kTrue, 0, 1); // //# 36: compi
le-time error | 68 const c = const AssertArgument.constLastSuper(kTrue, 0, 1); // //# 36: check
ed mode compile-time error |
69 const c = const AssertArgument.constMiddleSuper(kTrue, 0, 1); // //# 37: compi
le-time error | 69 const c = const AssertArgument.constMiddleSuper(kTrue, 0, 1); // //# 37: check
ed mode compile-time error |
70 const c = const AssertArgument.constMultiSuper(kTrue, 0, 1); // //# 38: compi
le-time error | 70 const c = const AssertArgument.constMultiSuper(kTrue, 0, 1); // //# 38: check
ed mode compile-time error |
71 | 71 |
72 const cTrue = const TrickCompare(true); | 72 const cTrue = const TrickCompare(true); |
73 // Value must be integer for potential-const expression to be actually const. | 73 // Value must be integer for potential-const expression to be actually const. |
74 const c = const AssertCompare.constFirst(cTrue, 2); // //# 41: compi
le-time error | 74 const c = const AssertCompare.constFirst(cTrue, 2); // //# 41: check
ed mode compile-time error |
75 const c = const AssertCompare.constLast(cTrue, 2); // //# 42: compi
le-time error | 75 const c = const AssertCompare.constLast(cTrue, 2); // //# 42: check
ed mode compile-time error |
76 const c = const AssertCompare.constMiddle(cTrue, 2); // //# 43: compi
le-time error | 76 const c = const AssertCompare.constMiddle(cTrue, 2); // //# 43: check
ed mode compile-time error |
77 const c = const AssertCompare.constMulti(cTrue, 2); // //# 44: compi
le-time error | 77 const c = const AssertCompare.constMulti(cTrue, 2); // //# 44: check
ed mode compile-time error |
78 const c = const AssertCompare.constFirstSuper(cTrue, 2); // //# 45: compi
le-time error | 78 const c = const AssertCompare.constFirstSuper(cTrue, 2); // //# 45: check
ed mode compile-time error |
79 const c = const AssertCompare.constLastSuper(cTrue, 2); // //# 46: compi
le-time error | 79 const c = const AssertCompare.constLastSuper(cTrue, 2); // //# 46: check
ed mode compile-time error |
80 const c = const AssertCompare.constMiddleSuper(cTrue, 2); // //# 47: compi
le-time error | 80 const c = const AssertCompare.constMiddleSuper(cTrue, 2); // //# 47: check
ed mode compile-time error |
81 const c = const AssertCompare.constMultiSuper(cTrue, 2); // //# 48: compi
le-time error | 81 const c = const AssertCompare.constMultiSuper(cTrue, 2); // //# 48: check
ed mode compile-time error |
82 } | 82 } |
83 | 83 |
84 | 84 |
85 void runtimeAsserts() { | 85 void runtimeAsserts() { |
86 | 86 |
87 testAssertArgumentCombinations(value, test, [testConst]) { | 87 testAssertArgumentCombinations(value, test, [testConst]) { |
88 test(() => new AssertArgument.first(value, 0, 1)); | 88 test(() => new AssertArgument.first(value, 0, 1)); |
89 test(() => new AssertArgument.last(value, 0, 1)); | 89 test(() => new AssertArgument.last(value, 0, 1)); |
90 test(() => new AssertArgument.middle(value, 0, 1)); | 90 test(() => new AssertArgument.middle(value, 0, 1)); |
91 test(() => new AssertArgument.multi(value, 0, 1)); | 91 test(() => new AssertArgument.multi(value, 0, 1)); |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 : y = y, assert(y < z), z = z, super(); | 219 : y = y, assert(y < z), z = z, super(); |
220 const AssertCompare.constMultiSuper(y, z) | 220 const AssertCompare.constMultiSuper(y, z) |
221 : assert(y < z), y = y, assert(y < z), z = z, assert(y < z), super(); | 221 : assert(y < z), y = y, assert(y < z), z = z, assert(y < z), super(); |
222 } | 222 } |
223 | 223 |
224 class TrickCompare { | 224 class TrickCompare { |
225 final result; | 225 final result; |
226 const TrickCompare(this.result); | 226 const TrickCompare(this.result); |
227 operator<(other) => result; // Nyah-nyah! | 227 operator<(other) => result; // Nyah-nyah! |
228 } | 228 } |
OLD | NEW |