| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 import 'package:expect/expect.dart'; | 5 import 'package:expect/expect.dart'; |
| 6 import 'multiline_newline_cr.dart' as cr; | 6 import 'multiline_newline_cr.dart' as cr; |
| 7 import 'multiline_newline_crlf.dart' as crlf; | 7 import 'multiline_newline_crlf.dart' as crlf; |
| 8 import 'multiline_newline_lf.dart' as lf; | 8 import 'multiline_newline_lf.dart' as lf; |
| 9 | 9 |
| 10 main() { | 10 main() { |
| 11 Expect.equals(4, cr.constantMultilineString.length); | 11 Expect.equals(4, cr.constantMultilineString.length); |
| 12 Expect.equals(4, crlf.constantMultilineString.length); | 12 Expect.equals(4, crlf.constantMultilineString.length); |
| 13 Expect.equals(4, lf.constantMultilineString.length); | 13 Expect.equals(4, lf.constantMultilineString.length); |
| 14 |
| 15 Expect.equals(6, cr.constantRawMultilineString.length); |
| 16 Expect.equals(6, crlf.constantRawMultilineString.length); |
| 17 Expect.equals(6, lf.constantRawMultilineString.length); |
| 18 |
| 14 Expect.equals(cr.constantMultilineString, crlf.constantMultilineString); | 19 Expect.equals(cr.constantMultilineString, crlf.constantMultilineString); |
| 15 Expect.equals(crlf.constantMultilineString, lf.constantMultilineString); | 20 Expect.equals(crlf.constantMultilineString, lf.constantMultilineString); |
| 16 Expect.equals(lf.constantMultilineString, cr.constantMultilineString); | 21 Expect.equals(lf.constantMultilineString, cr.constantMultilineString); |
| 17 | 22 |
| 23 Expect.equals(cr.constantRawMultilineString, crlf.constantRawMultilineString); |
| 24 Expect.equals(crlf.constantRawMultilineString, lf.constantRawMultilineString); |
| 25 Expect.equals(lf.constantRawMultilineString, cr.constantRawMultilineString); |
| 26 |
| 18 Expect.equals(4, cr.nonConstantMultilineString.length); | 27 Expect.equals(4, cr.nonConstantMultilineString.length); |
| 19 Expect.equals(4, crlf.nonConstantMultilineString.length); | 28 Expect.equals(4, crlf.nonConstantMultilineString.length); |
| 20 Expect.equals(4, lf.nonConstantMultilineString.length); | 29 Expect.equals(4, lf.nonConstantMultilineString.length); |
| 30 |
| 31 Expect.equals(6, cr.nonConstantRawMultilineString.length); |
| 32 Expect.equals(6, crlf.nonConstantRawMultilineString.length); |
| 33 Expect.equals(6, lf.nonConstantRawMultilineString.length); |
| 34 |
| 21 Expect.equals(cr.nonConstantMultilineString, crlf.nonConstantMultilineString); | 35 Expect.equals(cr.nonConstantMultilineString, crlf.nonConstantMultilineString); |
| 22 Expect.equals(crlf.nonConstantMultilineString, lf.nonConstantMultilineString); | 36 Expect.equals(crlf.nonConstantMultilineString, lf.nonConstantMultilineString); |
| 23 Expect.equals(lf.nonConstantMultilineString, cr.nonConstantMultilineString); | 37 Expect.equals(lf.nonConstantMultilineString, cr.nonConstantMultilineString); |
| 24 | 38 |
| 39 Expect.equals( |
| 40 cr.nonConstantRawMultilineString, crlf.nonConstantRawMultilineString); |
| 41 Expect.equals( |
| 42 crlf.nonConstantRawMultilineString, lf.nonConstantRawMultilineString); |
| 43 Expect.equals( |
| 44 lf.nonConstantRawMultilineString, cr.nonConstantRawMultilineString); |
| 45 |
| 25 const c1 = | 46 const c1 = |
| 26 cr.constantMultilineString == crlf.constantMultilineString ? true : null; | 47 cr.constantMultilineString == crlf.constantMultilineString ? true : null; |
| 27 const c2 = | 48 const c2 = |
| 28 crlf.constantMultilineString == lf.constantMultilineString ? true : null; | 49 crlf.constantMultilineString == lf.constantMultilineString ? true : null; |
| 29 const c3 = | 50 const c3 = |
| 30 lf.constantMultilineString == cr.constantMultilineString ? true : null; | 51 lf.constantMultilineString == cr.constantMultilineString ? true : null; |
| 31 Expect.isTrue(c1); | 52 Expect.isTrue(c1); |
| 32 Expect.isTrue(c2); | 53 Expect.isTrue(c2); |
| 33 Expect.isTrue(c3); | 54 Expect.isTrue(c3); |
| 34 | 55 |
| 35 const c4 = c1 ? 1 : 2; // //# 01: ok | 56 const c1r = cr.constantRawMultilineString == crlf.constantRawMultilineString |
| 36 Expect.equals(1, c4); // //# 01: continued | 57 ? true |
| 58 : null; |
| 59 const c2r = crlf.constantRawMultilineString == lf.constantRawMultilineString |
| 60 ? true |
| 61 : null; |
| 62 const c3r = lf.constantRawMultilineString == cr.constantRawMultilineString |
| 63 ? true |
| 64 : null; |
| 65 Expect.isTrue(c1r); |
| 66 Expect.isTrue(c2r); |
| 67 Expect.isTrue(c3r); |
| 37 | 68 |
| 38 const c5 = c2 ? 2 : 3; // //# 02: ok | 69 const c4 = c1 ? 1 : 2; //# 01: ok |
| 39 Expect.equals(2, c5); // //# 02: continued | 70 Expect.equals(1, c4); //# 01: continued |
| 40 | 71 |
| 41 const c6 = c3 ? 3 : 4; // //# 03: ok | 72 const c5 = c2 ? 2 : 3; //# 02: ok |
| 42 Expect.equals(3, c6); // //# 03: continued | 73 Expect.equals(2, c5); //# 02: continued |
| 74 |
| 75 const c6 = c3 ? 3 : 4; //# 03: ok |
| 76 Expect.equals(3, c6); //# 03: continued |
| 77 |
| 78 const c4r = c1r ? 1 : 2; //# 01r: ok |
| 79 Expect.equals(1, c4r); //# 01r: continued |
| 80 |
| 81 const c5r = c2r ? 2 : 3; //# 02r: ok |
| 82 Expect.equals(2, c5r); //# 02r: continued |
| 83 |
| 84 const c6r = c3r ? 3 : 4; //# 03r: ok |
| 85 Expect.equals(3, c6r); //# 03r: continued |
| 43 | 86 |
| 44 const c7 = | 87 const c7 = |
| 45 cr.constantMultilineString != crlf.constantMultilineString ? true : null; | 88 cr.constantMultilineString != crlf.constantMultilineString ? true : null; |
| 46 const c8 = | 89 const c8 = |
| 47 crlf.constantMultilineString != lf.constantMultilineString ? true : null; | 90 crlf.constantMultilineString != lf.constantMultilineString ? true : null; |
| 48 const c9 = | 91 const c9 = |
| 49 lf.constantMultilineString != cr.constantMultilineString ? true : null; | 92 lf.constantMultilineString != cr.constantMultilineString ? true : null; |
| 50 Expect.isNull(c7); | 93 Expect.isNull(c7); |
| 51 Expect.isNull(c8); | 94 Expect.isNull(c8); |
| 52 Expect.isNull(c9); | 95 Expect.isNull(c9); |
| 53 | 96 |
| 54 const c10 = c7 ? 1 : 2; // //# 04: compile-time error | 97 const c7r = cr.constantRawMultilineString != crlf.constantRawMultilineString |
| 55 const c11 = c8 ? 2 : 3; // //# 05: compile-time error | 98 ? true |
| 56 const c12 = c9 ? 3 : 4; // //# 06: compile-time error | 99 : null; |
| 100 const c8r = crlf.constantRawMultilineString != lf.constantRawMultilineString |
| 101 ? true |
| 102 : null; |
| 103 const c9r = lf.constantRawMultilineString != cr.constantRawMultilineString |
| 104 ? true |
| 105 : null; |
| 106 Expect.isNull(c7r); |
| 107 Expect.isNull(c8r); |
| 108 Expect.isNull(c9r); |
| 109 |
| 110 // What's the deal with the compile-time errors below? This is to validate |
| 111 // that constants are evaluated correctly at compile-time (or analysis |
| 112 // time). For example, only if [c7] is evaluated correctly does it become |
| 113 // null which leads to a compile-time error (as it isn't a boolean). For |
| 114 // tools like dart2js, this ensures that the compile-time evaluation of |
| 115 // constants is similar to the runtime evaluation tested above. For tools |
| 116 // like the analyzer, this ensures that evaluation is tested (there's no |
| 117 // runtime evaluation). |
| 118 const c10 = c7 ? 1 : 2; //# 04: compile-time error |
| 119 const c11 = c8 ? 2 : 3; //# 05: compile-time error |
| 120 const c12 = c9 ? 3 : 4; //# 06: compile-time error |
| 121 |
| 122 const c10r = c7r ? 1 : 2; //# 04r: compile-time error |
| 123 const c11r = c8r ? 2 : 3; //# 05r: compile-time error |
| 124 const c12r = c9r ? 3 : 4; //# 06r: compile-time error |
| 57 } | 125 } |
| OLD | NEW |