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

Unified Diff: tests/language/src/NamingTest.dart

Issue 8763001: Fix names with '$' to not conflict with operators or internal helpers (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merged again Created 9 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 | « frog/world.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/language/src/NamingTest.dart
diff --git a/tests/language/src/NamingTest.dart b/tests/language/src/NamingTest.dart
index 49416a490bddb6ec42b2de1acf36291f88c2a50d..264ee5131193e576a030f2a272e34e8ad956031e 100644
--- a/tests/language/src/NamingTest.dart
+++ b/tests/language/src/NamingTest.dart
@@ -452,6 +452,16 @@ class NamingTest {
Expect.equals(499, EOS + ILLEGAL);
}
+ static testDollar() {
+ Expect.equals(123, $(123).wrapped);
+ var x = new Object(), y = new Object();
+ Expect.identical(x, $(x).wrapped);
+ Expect.identical(y, $(x).$add(y));
+ Expect.identical(x, $(x).$negate());
+ Expect.equals(123, $(x) + x);
+ Expect.equals(444, -$(x));
+ }
+
static void testMain() {
count = 0;
testExceptionNaming();
@@ -464,12 +474,27 @@ class NamingTest {
Bug4082360.test();
Hoisting.test();
testPseudoTokens();
+ testDollar();
}
}
+// Test that the generated JS names don't conflict with "$"
+class DartQuery {
+ Object wrapped;
+ DartQuery(this.wrapped);
+
+ $add(Object other) => other;
+ $negate() => wrapped;
+
+ operator +(Object other) => 123;
+ operator negate() => 444;
+}
+
+$add(Object first, Object second) => second;
+DartQuery $(Object obj) => new DartQuery(obj);
// Ensure we don't have false positive. named constructor and methods
-// are in different namespaces, therefore it is ok to have a method
+// are in different namespaces, therefore it is ok to have a method
// called foo and a named constructor CLASS.foo
class Naming1Test {
Naming1Test.foo() { }
@@ -489,7 +514,7 @@ class Naming2Test {
static void main(args) {
var a = new Naming2Test();
- a.foo(2);
+ Expect.throws(() => a.foo(2), (e) => e is ObjectNotClosureException);
}
}
@@ -497,14 +522,17 @@ class Naming2Test {
class Naming3Test {
Naming3Test() { }
operator negate() { }
- negate() { }
+ negate() => 777;
static void main(args) {
var a = new Naming3Test();
- a.negate(3);
+ Expect.equals(777, a.negate());
}
}
main() {
NamingTest.testMain();
+ Naming1Test.main(null);
+ Naming2Test.main(null);
+ Naming3Test.main(null);
}
« no previous file with comments | « frog/world.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698