Index: tests/language/src/NamedParametersWithObjectPropertyNamesTest.dart |
diff --git a/tests/language/src/NamedParametersWithObjectPropertyNamesTest.dart b/tests/language/src/NamedParametersWithObjectPropertyNamesTest.dart |
new file mode 100644 |
index 0000000000000000000000000000000000000000..d742df1822253228bd743a99fb282ffeb261dacb |
--- /dev/null |
+++ b/tests/language/src/NamedParametersWithObjectPropertyNamesTest.dart |
@@ -0,0 +1,364 @@ |
+// Copyright (c) 2011, 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. |
+ |
+// Test for named parameter with the name of a JavaScript property found on |
+// 'Object'. For such a NAME, foo.NAME may exist in an empty map, i.e. |
+// 'toString' in {} --> true. |
+ |
+ |
+main() { |
+ // Test properties found on instances of Object in Chrome 15 and Firefox 6. |
+ test_constructor(); |
+ test___proto__(); |
+ test___defineGetter__(); |
+ test___defineSetter__(); |
+ test___lookupGetter__(); |
+ test___lookupSetter__(); |
+ test___noSuchMethod__(); |
+ test_hasOwnProperty(); |
+ test_isPrototypeOf(); |
+ test_propertyIsEnumerable(); |
+ test_toSource(); |
+ test_toLocaleString(); |
+ test_toString(); |
+ test_unwatch(); |
+ test_valueOf(); |
+ test_watch(); |
+} |
+ |
+// 'constructor' property. |
+ |
+class TestClass_constructor { |
+ method([constructor]) => constructor; |
+ static staticMethod([constructor]) => constructor; |
+} |
+globalMethod_constructor([constructor]) => constructor; |
+ |
+test_constructor() { |
+ var obj = new TestClass_constructor(); |
+ |
+ Expect.equals(null, obj.method()); |
+ Expect.equals(0, obj.method(constructor: 0)); |
+ |
+ Expect.equals(null, TestClass_constructor.staticMethod()); |
+ Expect.equals(0, TestClass_constructor.staticMethod(constructor: 0)); |
+ |
+ Expect.equals(null, globalMethod_constructor()); |
+ Expect.equals(0, globalMethod_constructor(constructor: 0)); |
+} |
+ |
+// '__proto__' property. |
+ |
+class TestClass___proto__ { |
+ method([__proto__]) => __proto__; |
+ static staticMethod([__proto__]) => __proto__; |
+} |
+globalMethod___proto__([__proto__]) => __proto__; |
+ |
+test___proto__() { |
+ var obj = new TestClass___proto__(); |
+ |
+ Expect.equals(null, obj.method()); |
+ Expect.equals(0, obj.method(__proto__: 0)); |
+ |
+ Expect.equals(null, TestClass___proto__.staticMethod()); |
+ Expect.equals(0, TestClass___proto__.staticMethod(__proto__: 0)); |
+ |
+ Expect.equals(null, globalMethod___proto__()); |
+ Expect.equals(0, globalMethod___proto__(__proto__: 0)); |
+} |
+ |
+// '__defineGetter__' property. |
+ |
+class TestClass___defineGetter__ { |
+ method([__defineGetter__]) => __defineGetter__; |
+ static staticMethod([__defineGetter__]) => __defineGetter__; |
+} |
+globalMethod___defineGetter__([__defineGetter__]) => __defineGetter__; |
+ |
+test___defineGetter__() { |
+ var obj = new TestClass___defineGetter__(); |
+ |
+ Expect.equals(null, obj.method()); |
+ Expect.equals(0, obj.method(__defineGetter__: 0)); |
+ |
+ Expect.equals(null, TestClass___defineGetter__.staticMethod()); |
+ Expect.equals(0, TestClass___defineGetter__.staticMethod(__defineGetter__: 0)); |
+ |
+ Expect.equals(null, globalMethod___defineGetter__()); |
+ Expect.equals(0, globalMethod___defineGetter__(__defineGetter__: 0)); |
+} |
+ |
+// '__defineSetter__' property. |
+ |
+class TestClass___defineSetter__ { |
+ method([__defineSetter__]) => __defineSetter__; |
+ static staticMethod([__defineSetter__]) => __defineSetter__; |
+} |
+globalMethod___defineSetter__([__defineSetter__]) => __defineSetter__; |
+ |
+test___defineSetter__() { |
+ var obj = new TestClass___defineSetter__(); |
+ |
+ Expect.equals(null, obj.method()); |
+ Expect.equals(0, obj.method(__defineSetter__: 0)); |
+ |
+ Expect.equals(null, TestClass___defineSetter__.staticMethod()); |
+ Expect.equals(0, TestClass___defineSetter__.staticMethod(__defineSetter__: 0)); |
+ |
+ Expect.equals(null, globalMethod___defineSetter__()); |
+ Expect.equals(0, globalMethod___defineSetter__(__defineSetter__: 0)); |
+} |
+ |
+// '__lookupGetter__' property. |
+ |
+class TestClass___lookupGetter__ { |
+ method([__lookupGetter__]) => __lookupGetter__; |
+ static staticMethod([__lookupGetter__]) => __lookupGetter__; |
+} |
+globalMethod___lookupGetter__([__lookupGetter__]) => __lookupGetter__; |
+ |
+test___lookupGetter__() { |
+ var obj = new TestClass___lookupGetter__(); |
+ |
+ Expect.equals(null, obj.method()); |
+ Expect.equals(0, obj.method(__lookupGetter__: 0)); |
+ |
+ Expect.equals(null, TestClass___lookupGetter__.staticMethod()); |
+ Expect.equals(0, TestClass___lookupGetter__.staticMethod(__lookupGetter__: 0)); |
+ |
+ Expect.equals(null, globalMethod___lookupGetter__()); |
+ Expect.equals(0, globalMethod___lookupGetter__(__lookupGetter__: 0)); |
+} |
+ |
+// '__lookupSetter__' property. |
+ |
+class TestClass___lookupSetter__ { |
+ method([__lookupSetter__]) => __lookupSetter__; |
+ static staticMethod([__lookupSetter__]) => __lookupSetter__; |
+} |
+globalMethod___lookupSetter__([__lookupSetter__]) => __lookupSetter__; |
+ |
+test___lookupSetter__() { |
+ var obj = new TestClass___lookupSetter__(); |
+ |
+ Expect.equals(null, obj.method()); |
+ Expect.equals(0, obj.method(__lookupSetter__: 0)); |
+ |
+ Expect.equals(null, TestClass___lookupSetter__.staticMethod()); |
+ Expect.equals(0, TestClass___lookupSetter__.staticMethod(__lookupSetter__: 0)); |
+ |
+ Expect.equals(null, globalMethod___lookupSetter__()); |
+ Expect.equals(0, globalMethod___lookupSetter__(__lookupSetter__: 0)); |
+} |
+ |
+// '__noSuchMethod__' property. |
+ |
+class TestClass___noSuchMethod__ { |
+ method([__noSuchMethod__]) => __noSuchMethod__; |
+ static staticMethod([__noSuchMethod__]) => __noSuchMethod__; |
+} |
+globalMethod___noSuchMethod__([__noSuchMethod__]) => __noSuchMethod__; |
+ |
+test___noSuchMethod__() { |
+ var obj = new TestClass___noSuchMethod__(); |
+ |
+ Expect.equals(null, obj.method()); |
+ Expect.equals(0, obj.method(__noSuchMethod__: 0)); |
+ |
+ Expect.equals(null, TestClass___noSuchMethod__.staticMethod()); |
+ Expect.equals(0, TestClass___noSuchMethod__.staticMethod(__noSuchMethod__: 0)); |
+ |
+ Expect.equals(null, globalMethod___noSuchMethod__()); |
+ Expect.equals(0, globalMethod___noSuchMethod__(__noSuchMethod__: 0)); |
+} |
+ |
+// 'hasOwnProperty' property. |
+ |
+class TestClass_hasOwnProperty { |
+ method([hasOwnProperty]) => hasOwnProperty; |
+ static staticMethod([hasOwnProperty]) => hasOwnProperty; |
+} |
+globalMethod_hasOwnProperty([hasOwnProperty]) => hasOwnProperty; |
+ |
+test_hasOwnProperty() { |
+ var obj = new TestClass_hasOwnProperty(); |
+ |
+ Expect.equals(null, obj.method()); |
+ Expect.equals(0, obj.method(hasOwnProperty: 0)); |
+ |
+ Expect.equals(null, TestClass_hasOwnProperty.staticMethod()); |
+ Expect.equals(0, TestClass_hasOwnProperty.staticMethod(hasOwnProperty: 0)); |
+ |
+ Expect.equals(null, globalMethod_hasOwnProperty()); |
+ Expect.equals(0, globalMethod_hasOwnProperty(hasOwnProperty: 0)); |
+} |
+ |
+// 'isPrototypeOf' property. |
+ |
+class TestClass_isPrototypeOf { |
+ method([isPrototypeOf]) => isPrototypeOf; |
+ static staticMethod([isPrototypeOf]) => isPrototypeOf; |
+} |
+globalMethod_isPrototypeOf([isPrototypeOf]) => isPrototypeOf; |
+ |
+test_isPrototypeOf() { |
+ var obj = new TestClass_isPrototypeOf(); |
+ |
+ Expect.equals(null, obj.method()); |
+ Expect.equals(0, obj.method(isPrototypeOf: 0)); |
+ |
+ Expect.equals(null, TestClass_isPrototypeOf.staticMethod()); |
+ Expect.equals(0, TestClass_isPrototypeOf.staticMethod(isPrototypeOf: 0)); |
+ |
+ Expect.equals(null, globalMethod_isPrototypeOf()); |
+ Expect.equals(0, globalMethod_isPrototypeOf(isPrototypeOf: 0)); |
+} |
+ |
+// 'propertyIsEnumerable' property. |
+ |
+class TestClass_propertyIsEnumerable { |
+ method([propertyIsEnumerable]) => propertyIsEnumerable; |
+ static staticMethod([propertyIsEnumerable]) => propertyIsEnumerable; |
+} |
+globalMethod_propertyIsEnumerable([propertyIsEnumerable]) => propertyIsEnumerable; |
+ |
+test_propertyIsEnumerable() { |
+ var obj = new TestClass_propertyIsEnumerable(); |
+ |
+ Expect.equals(null, obj.method()); |
+ Expect.equals(0, obj.method(propertyIsEnumerable: 0)); |
+ |
+ Expect.equals(null, TestClass_propertyIsEnumerable.staticMethod()); |
+ Expect.equals(0, TestClass_propertyIsEnumerable.staticMethod(propertyIsEnumerable: 0)); |
+ |
+ Expect.equals(null, globalMethod_propertyIsEnumerable()); |
+ Expect.equals(0, globalMethod_propertyIsEnumerable(propertyIsEnumerable: 0)); |
+} |
+ |
+// 'toSource' property. |
+ |
+class TestClass_toSource { |
+ method([toSource]) => toSource; |
+ static staticMethod([toSource]) => toSource; |
+} |
+globalMethod_toSource([toSource]) => toSource; |
+ |
+test_toSource() { |
+ var obj = new TestClass_toSource(); |
+ |
+ Expect.equals(null, obj.method()); |
+ Expect.equals(0, obj.method(toSource: 0)); |
+ |
+ Expect.equals(null, TestClass_toSource.staticMethod()); |
+ Expect.equals(0, TestClass_toSource.staticMethod(toSource: 0)); |
+ |
+ Expect.equals(null, globalMethod_toSource()); |
+ Expect.equals(0, globalMethod_toSource(toSource: 0)); |
+} |
+ |
+// 'toLocaleString' property. |
+ |
+class TestClass_toLocaleString { |
+ method([toLocaleString]) => toLocaleString; |
+ static staticMethod([toLocaleString]) => toLocaleString; |
+} |
+globalMethod_toLocaleString([toLocaleString]) => toLocaleString; |
+ |
+test_toLocaleString() { |
+ var obj = new TestClass_toLocaleString(); |
+ |
+ Expect.equals(null, obj.method()); |
+ Expect.equals(0, obj.method(toLocaleString: 0)); |
+ |
+ Expect.equals(null, TestClass_toLocaleString.staticMethod()); |
+ Expect.equals(0, TestClass_toLocaleString.staticMethod(toLocaleString: 0)); |
+ |
+ Expect.equals(null, globalMethod_toLocaleString()); |
+ Expect.equals(0, globalMethod_toLocaleString(toLocaleString: 0)); |
+} |
+ |
+// 'toString' property. |
+ |
+class TestClass_toString { |
+ method([toString]) => toString; |
+ static staticMethod([toString]) => toString; |
+} |
+globalMethod_toString([toString]) => toString; |
+ |
+test_toString() { |
+ var obj = new TestClass_toString(); |
+ |
+ Expect.equals(null, obj.method()); |
+ Expect.equals(0, obj.method(toString: 0)); |
+ |
+ Expect.equals(null, TestClass_toString.staticMethod()); |
+ Expect.equals(0, TestClass_toString.staticMethod(toString: 0)); |
+ |
+ Expect.equals(null, globalMethod_toString()); |
+ Expect.equals(0, globalMethod_toString(toString: 0)); |
+} |
+ |
+// 'unwatch' property. |
+ |
+class TestClass_unwatch { |
+ method([unwatch]) => unwatch; |
+ static staticMethod([unwatch]) => unwatch; |
+} |
+globalMethod_unwatch([unwatch]) => unwatch; |
+ |
+test_unwatch() { |
+ var obj = new TestClass_unwatch(); |
+ |
+ Expect.equals(null, obj.method()); |
+ Expect.equals(0, obj.method(unwatch: 0)); |
+ |
+ Expect.equals(null, TestClass_unwatch.staticMethod()); |
+ Expect.equals(0, TestClass_unwatch.staticMethod(unwatch: 0)); |
+ |
+ Expect.equals(null, globalMethod_unwatch()); |
+ Expect.equals(0, globalMethod_unwatch(unwatch: 0)); |
+} |
+ |
+// 'valueOf' property. |
+ |
+class TestClass_valueOf { |
+ method([valueOf]) => valueOf; |
+ static staticMethod([valueOf]) => valueOf; |
+} |
+globalMethod_valueOf([valueOf]) => valueOf; |
+ |
+test_valueOf() { |
+ var obj = new TestClass_valueOf(); |
+ |
+ Expect.equals(null, obj.method()); |
+ Expect.equals(0, obj.method(valueOf: 0)); |
+ |
+ Expect.equals(null, TestClass_valueOf.staticMethod()); |
+ Expect.equals(0, TestClass_valueOf.staticMethod(valueOf: 0)); |
+ |
+ Expect.equals(null, globalMethod_valueOf()); |
+ Expect.equals(0, globalMethod_valueOf(valueOf: 0)); |
+} |
+ |
+// 'watch' property. |
+ |
+class TestClass_watch { |
+ method([watch]) => watch; |
+ static staticMethod([watch]) => watch; |
+} |
+globalMethod_watch([watch]) => watch; |
+ |
+test_watch() { |
+ var obj = new TestClass_watch(); |
+ |
+ Expect.equals(null, obj.method()); |
+ Expect.equals(0, obj.method(watch: 0)); |
+ |
+ Expect.equals(null, TestClass_watch.staticMethod()); |
+ Expect.equals(0, TestClass_watch.staticMethod(watch: 0)); |
+ |
+ Expect.equals(null, globalMethod_watch()); |
+ Expect.equals(0, globalMethod_watch(watch: 0)); |
+} |