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

Unified Diff: tests/standalone/assert_test.dart

Issue 10915083: Change assert implementation to not depend on a top-level function called 'assert'. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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 side-by-side diff with in-line comments
Download patch
Index: tests/standalone/assert_test.dart
diff --git a/tests/standalone/assert_test.dart b/tests/standalone/assert_test.dart
index 8e1b288e5b28002e95553e6903e37097bdde2c11..7655ff07eaf5ff1e049014952e2c90bf593bf30b 100644
--- a/tests/standalone/assert_test.dart
+++ b/tests/standalone/assert_test.dart
@@ -49,6 +49,144 @@ class AssertTest {
}
}
+// A function that accepts 0-2 arguments.
+void poly([a, b]) {
+ polyCount++;
+ polyArg = a;
+}
+// First argument of most recent call to poly.
+var polyArg = 0;
+// Number of calls to poly.
+var polyCount = 0;
+
+class SuperGet {
+ get assert => poly;
+}
+
+class SuperMethod {
+ assert([a, b]) => poly(a, b);
+}
+
+class SuperField {
+ var assert;
+ SuperField() : assert = poly;
+}
+
+class SuperNon {
+ noSuchMethod(x, y) => poly.apply(y);
+}
+
+class SubGet extends SuperGet {
+ void getAssert() {
+ assert;
+ }
+ void assert0() {
+ assert();
+ }
+ void assert1(x) {
+ assert(x);
+ }
+ void assertExp1(x) {
+ var z = assert(x);
+ }
+ void assert2(x) {
+ assert(x, x);
+ }
+}
+
+class SubMethod extends SuperMethod {
+ void getAssert() {
+ assert;
+ }
+ void assert0() {
+ assert();
+ }
+ void assert1(x) {
+ assert(x);
+ }
+ void assertExp1(x) {
+ var z = assert(x);
+ }
+ void assert2(x) {
+ assert(x, x);
+ }
+}
+
+class SubField extends SuperField {
+ void getAssert() {
+ assert;
+ }
+ void assert0() {
+ assert();
+ }
+ void assert1(x) {
+ assert(x);
+ }
+ void assertExp(x) {
+ var z = assert(x);
+ }
+ void assert2(x) {
+ assert(x, x);
+ }
+}
+
+class SubNon extends SuperNon {
+ void getAssert() {
+ assert;
+ }
+ assert0() {
+ assert();
+ }
+ void assert1(x) {
+ assert(x);
+ }
+ void assertExp(x) {
+ var z = assert(x);
+ }
+ void assert2(x) {
+ assert(x, x);
+ }
+}
+
+
+testSuperAssert() {
+ var get = new SubGet();
+ var method = new SubMethod();
+ var field = new SubField();
+ var non = new SubNon();
+
+ function expectCallsPoly(code) {
+ int oldPolyCount = polyCount;
+ int newPolyArg = polyArg + 1;
+ code(newPolyArg);
+ Expect.equals(oldPolyCount + 1, polyCount);
+ Expect.equals(newPolyArg, polyArg);
+ }
+
+ expectAssert(code, [bool noArgument = false]) {
+ int oldPolyCount = polyCount;
+ try {
+ code(polyArg + 1);
+ Expect.fail();
+ } on AssertionError catch (e) {
+ }
+ Expect.equals(oldPolyCount, polyCount);
+ }
+
+ void testAssert(object) {
+ object.getAssert(); // Doesn't fail.
+ expectCallsPoly(object.assert0(), true); // Not an assert.
+ expectAssert(object.assert1); // Is real assert.
+ expectCallsPoly(object.assertExp); // Not an assert in expression position.
+ expectCallsPoly(object.assert2); // Not an assert with two arguments.
+ }
+
+ testAssert(get);
+ testAssert(method);
+ testAssert(field);
+ testAssert(non);
Johnni Winther 2012/09/05 09:07:05 I see no tests for when an assert method is in lex
Lasse Reichstein Nielsen 2012/09/05 12:51:20 True, let's add that too. I'll add a lexicalAssert
+}
+
main() {
AssertTest.testMain();
}
« lib/compiler/implementation/scanner/keyword.dart ('K') | « tests/language/language_dart2js.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698