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

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

Issue 2116483002: Handle constant ?? expressions in constructors. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 5 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) 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 library constant_expression_test; 5 library constant_expression_test;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'package:async_helper/async_helper.dart'; 8 import 'package:async_helper/async_helper.dart';
9 import 'package:expect/expect.dart'; 9 import 'package:expect/expect.dart';
10 import 'package:compiler/src/constants/expressions.dart'; 10 import 'package:compiler/src/constants/expressions.dart';
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 const TestData('', const [ 46 const TestData('', const [
47 const ConstantData('null', ConstantExpressionKind.NULL), 47 const ConstantData('null', ConstantExpressionKind.NULL),
48 const ConstantData('false', ConstantExpressionKind.BOOL), 48 const ConstantData('false', ConstantExpressionKind.BOOL),
49 const ConstantData('true', ConstantExpressionKind.BOOL), 49 const ConstantData('true', ConstantExpressionKind.BOOL),
50 const ConstantData('0', ConstantExpressionKind.INT), 50 const ConstantData('0', ConstantExpressionKind.INT),
51 const ConstantData('0.0', ConstantExpressionKind.DOUBLE), 51 const ConstantData('0.0', ConstantExpressionKind.DOUBLE),
52 const ConstantData('"foo"', ConstantExpressionKind.STRING), 52 const ConstantData('"foo"', ConstantExpressionKind.STRING),
53 const ConstantData('1 + 2', ConstantExpressionKind.BINARY), 53 const ConstantData('1 + 2', ConstantExpressionKind.BINARY),
54 const ConstantData('1 == 2', ConstantExpressionKind.BINARY), 54 const ConstantData('1 == 2', ConstantExpressionKind.BINARY),
55 const ConstantData('1 != 2', ConstantExpressionKind.BINARY), 55 const ConstantData('1 != 2', ConstantExpressionKind.BINARY),
56 const ConstantData('1 ?? 2', ConstantExpressionKind.BINARY),
56 const ConstantData('-(1)', ConstantExpressionKind.UNARY, text: '-1'), 57 const ConstantData('-(1)', ConstantExpressionKind.UNARY, text: '-1'),
57 const ConstantData('"foo".length', ConstantExpressionKind.STRING_LENGTH), 58 const ConstantData('"foo".length', ConstantExpressionKind.STRING_LENGTH),
58 const ConstantData('identical(0, 1)', ConstantExpressionKind.IDENTICAL), 59 const ConstantData('identical(0, 1)', ConstantExpressionKind.IDENTICAL),
59 const ConstantData('"a" "b"', ConstantExpressionKind.CONCATENATE, 60 const ConstantData('"a" "b"', ConstantExpressionKind.CONCATENATE,
60 text: '"ab"'), 61 text: '"ab"'),
61 const ConstantData('identical', ConstantExpressionKind.FUNCTION), 62 const ConstantData('identical', ConstantExpressionKind.FUNCTION),
62 const ConstantData('true ? 0 : 1', ConstantExpressionKind.CONDITIONAL), 63 const ConstantData('true ? 0 : 1', ConstantExpressionKind.CONDITIONAL),
63 const ConstantData('proxy', ConstantExpressionKind.VARIABLE), 64 const ConstantData('proxy', ConstantExpressionKind.VARIABLE),
64 const ConstantData('Object', ConstantExpressionKind.TYPE), 65 const ConstantData('Object', ConstantExpressionKind.TYPE),
65 const ConstantData('#name', ConstantExpressionKind.SYMBOL), 66 const ConstantData('#name', ConstantExpressionKind.SYMBOL),
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 String name = '$field'; 240 String name = '$field';
240 String expression = instanceFields[field].toDartText(); 241 String expression = instanceFields[field].toDartText();
241 String expected = data.fields[name]; 242 String expected = data.fields[name];
242 Expect.equals(expected, expression, 243 Expect.equals(expected, expression,
243 "Unexpected field expression ${expression} for field '$name' in " 244 "Unexpected field expression ${expression} for field '$name' in "
244 "contant `${constant.toDartText()}`, expected '${expected}'."); 245 "contant `${constant.toDartText()}`, expected '${expected}'.");
245 }); 246 });
246 } 247 }
247 }); 248 });
248 } 249 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/serialization/element_serialization.dart ('k') | tests/compiler/dart2js/serialization/test_data.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698