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

Unified Diff: tests/compiler/dart2js_native/js_constant_test.dart

Issue 1438633002: js_ast: Avoid precedence issue with negative numbers as receivers at calls (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/compiler/dart2js/js_constant_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/compiler/dart2js_native/js_constant_test.dart
diff --git a/tests/compiler/dart2js_native/js_constant_test.dart b/tests/compiler/dart2js_native/js_constant_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..19b2e6f9f1fe6f3055310886213bb895ea5376a3
--- /dev/null
+++ b/tests/compiler/dart2js_native/js_constant_test.dart
@@ -0,0 +1,44 @@
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'dart:_foreign_helper' show JS;
+import "package:expect/expect.dart";
+
+// Negative constant numbers must be generated as negation, not just a literal
+// with a sign, i.e.
+//
+// (-5).toString()
+//
+// not
+//
+// -5 .toString()
+//
+// The unparethesized version is `-(5 .toString())`, which creates the string
+// `"5"`, then converts it to a number for negation, giving a number result
+// instead of a string result.
+
+@NoInline()
+checkString(r) {
+ Expect.isTrue(r is String,
+ 'Expected string, found ${r} of type ${r.runtimeType}');
+}
+
+test1() {
+ checkString(JS('', '#.toString()', -5));
+}
+
+test2() {
+ checkString(JS('', '#.toString()', -1.5));
+}
+
+test3() {
+ checkString(JS('', '#.toString()', -0.0));
+}
+
+
+main() {
+ test1();
+ test2();
+ test3();
+}
« no previous file with comments | « tests/compiler/dart2js/js_constant_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698