Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(532)

Side by Side Diff: tests/compiler/dart2js/const_exp_test.dart

Issue 2345083003: dart2js: run dartfmt on tests (Closed)
Patch Set: revert another multipart test Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 'dart:async'; 5 import 'dart:async';
6 import 'package:async_helper/async_helper.dart'; 6 import 'package:async_helper/async_helper.dart';
7 import 'package:expect/expect.dart'; 7 import 'package:expect/expect.dart';
8 import 'type_test_helper.dart'; 8 import 'type_test_helper.dart';
9 9
10 test(String constantInitializer, [String expectedOutput]) { 10 test(String constantInitializer, [String expectedOutput]) {
11 if (expectedOutput == null) { 11 if (expectedOutput == null) {
12 expectedOutput = constantInitializer; 12 expectedOutput = constantInitializer;
13 } 13 }
14 return () => TypeEnvironment.create(""" 14 return () => TypeEnvironment
15 .create(
16 """
15 class Class<T, S> { 17 class Class<T, S> {
16 final a; 18 final a;
17 final b; 19 final b;
18 final c; 20 final c;
19 const Class(this.a, {this.b, this.c: true}); 21 const Class(this.a, {this.b, this.c: true});
20 const Class.named([this.a, this.b = 0, this.c = 2]); 22 const Class.named([this.a, this.b = 0, this.c = 2]);
21 23
22 static const staticConstant = 0; 24 static const staticConstant = 0;
23 static staticFunction() {} 25 static staticFunction() {}
24 } 26 }
25 const t = true; 27 const t = true;
26 const f = false; 28 const f = false;
27 const toplevelConstant = 0; 29 const toplevelConstant = 0;
28 toplevelFunction() {} 30 toplevelFunction() {}
29 const constant = $constantInitializer; 31 const constant = $constantInitializer;
30 """, expectNoWarningsOrErrors: true).then((env) { 32 """,
31 var element = env.getElement('constant'); 33 expectNoWarningsOrErrors: true)
32 Expect.isNotNull(element, "Element 'constant' not found."); 34 .then((env) {
33 var constant = element.constant; 35 var element = env.getElement('constant');
34 var value = env.compiler.constants.getConstantValue(constant); 36 Expect.isNotNull(element, "Element 'constant' not found.");
35 Expect.isNotNull(constant, 37 var constant = element.constant;
36 "No constant computed for '$element'."); 38 var value = env.compiler.constants.getConstantValue(constant);
37 Expect.equals(expectedOutput, constant.toDartText(), 39 Expect.isNotNull(constant, "No constant computed for '$element'.");
38 "Unexpected to string '${constant.toDartText()}' for constant " 40 Expect.equals(
39 "'$constantInitializer' of value " 41 expectedOutput,
40 "${value.toStructuredText()}"); 42 constant.toDartText(),
41 }); 43 "Unexpected to string '${constant.toDartText()}' for constant "
44 "'$constantInitializer' of value "
45 "${value.toStructuredText()}");
46 });
42 } 47 }
43 48
44 void main() { 49 void main() {
45 asyncTest(() => Future.forEach([ 50 asyncTest(() => Future.forEach([
46 test('null'), 51 test('null'),
47 test('0'), 52 test('0'),
48 test('1.5'), 53 test('1.5'),
49 test('true'), 54 test('true'),
50 test('false'), 55 test('false'),
51 test('"f"'), 56 test('"f"'),
52 test('"a" "b"', '"ab"'), 57 test('"a" "b"', '"ab"'),
53 test('const []'), 58 test('const []'),
54 test('const <int>[0, 1]'), 59 test('const <int>[0, 1]'),
55 test('const <dynamic>[0, 1]', 'const [0, 1]'), 60 test('const <dynamic>[0, 1]', 'const [0, 1]'),
56 test('const {}'), 61 test('const {}'),
57 test('const {0: 1, 2: 3}'), 62 test('const {0: 1, 2: 3}'),
58 test('const <String, int>{"0": 1, "2": 3}'), 63 test('const <String, int>{"0": 1, "2": 3}'),
59 test('const <String, dynamic>{"0": 1, "2": 3}'), 64 test('const <String, dynamic>{"0": 1, "2": 3}'),
60 test('const <dynamic, dynamic>{"0": 1, "2": 3}', 'const {"0": 1, "2": 3}'), 65 test('const <dynamic, dynamic>{"0": 1, "2": 3}',
61 test('const Class(0)'), 66 'const {"0": 1, "2": 3}'),
62 test('const Class(0, b: 1)'), 67 test('const Class(0)'),
63 test('const Class(0, c: 2)'), 68 test('const Class(0, b: 1)'),
64 test('const Class(0, b: 3, c: 4)'), 69 test('const Class(0, c: 2)'),
65 test('const Class.named()'), 70 test('const Class(0, b: 3, c: 4)'),
66 test('const Class.named(0)'), 71 test('const Class.named()'),
67 test('const Class.named(0, 1)'), 72 test('const Class.named(0)'),
68 test('const Class.named(0, 1, 2)'), 73 test('const Class.named(0, 1)'),
69 test('const Class<String, int>(0)'), 74 test('const Class.named(0, 1, 2)'),
70 test('const Class<String, dynamic>(0)'), 75 test('const Class<String, int>(0)'),
71 test('const Class<dynamic, String>(0)'), 76 test('const Class<String, dynamic>(0)'),
72 test('const Class<dynamic, dynamic>(0)', 'const Class(0)'), 77 test('const Class<dynamic, String>(0)'),
73 test('toplevelConstant'), 78 test('const Class<dynamic, dynamic>(0)', 'const Class(0)'),
74 test('toplevelFunction'), 79 test('toplevelConstant'),
75 test('Class.staticConstant'), 80 test('toplevelFunction'),
76 test('Class.staticFunction'), 81 test('Class.staticConstant'),
77 test('#a'), 82 test('Class.staticFunction'),
78 test('1 + 2'), 83 test('#a'),
79 test('1 + 2 + 3'), 84 test('1 + 2'),
80 test('1 + -2'), 85 test('1 + 2 + 3'),
81 test('-1 + 2'), 86 test('1 + -2'),
82 test('(1 + 2) + 3', '1 + 2 + 3'), 87 test('-1 + 2'),
83 test('1 + (2 + 3)', '1 + 2 + 3'), 88 test('(1 + 2) + 3', '1 + 2 + 3'),
84 test('1 * 2'), 89 test('1 + (2 + 3)', '1 + 2 + 3'),
85 test('1 * 2 + 3'), 90 test('1 * 2'),
86 test('1 * (2 + 3)'), 91 test('1 * 2 + 3'),
87 test('1 + 2 * 3'), 92 test('1 * (2 + 3)'),
88 test('(1 + 2) * 3'), 93 test('1 + 2 * 3'),
89 test('false || identical(0, 1)'), 94 test('(1 + 2) * 3'),
90 test('!identical(0, 1)'), 95 test('false || identical(0, 1)'),
91 test('!identical(0, 1) || false'), 96 test('!identical(0, 1)'),
92 test('!(identical(0, 1) || false)'), 97 test('!identical(0, 1) || false'),
93 test('identical(0, 1) ? 3 * 4 + 5 : 6 + 7 * 8'), 98 test('!(identical(0, 1) || false)'),
94 test('t ? f ? 0 : 1 : 2'), 99 test('identical(0, 1) ? 3 * 4 + 5 : 6 + 7 * 8'),
95 test('(t ? t : f) ? f ? 0 : 1 : 2'), 100 test('t ? f ? 0 : 1 : 2'),
96 test('t ? t : f ? f ? 0 : 1 : 2'), 101 test('(t ? t : f) ? f ? 0 : 1 : 2'),
97 test('t ? t ? t : t : t ? t : t'), 102 test('t ? t : f ? f ? 0 : 1 : 2'),
98 test('t ? (t ? t : t) : (t ? t : t)', 103 test('t ? t ? t : t : t ? t : t'),
99 't ? t ? t : t : t ? t : t'), 104 test('t ? (t ? t : t) : (t ? t : t)', 't ? t ? t : t : t ? t : t'),
100 test('const [const <dynamic, dynamic>{0: true, "1": "c" "d"}, ' 105 test(
101 'const Class(const Class<dynamic, dynamic>(toplevelConstant))]', 106 'const [const <dynamic, dynamic>{0: true, "1": "c" "d"}, '
102 'const [const {0: true, "1": "cd"}, ' 107 'const Class(const Class<dynamic, dynamic>(toplevelConstant))]',
103 'const Class(const Class(toplevelConstant))]'), 108 'const [const {0: true, "1": "cd"}, '
104 ], (f) => f())); 109 'const Class(const Class(toplevelConstant))]'),
105 } 110 ], (f) => f()));
111 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698