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

Unified Diff: dart/tests/language/argument_definition_test.dart

Issue 10916050: Extend testing of argument definition test expressions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 4 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
« no previous file with comments | « no previous file | dart/tests/language/language_dart2js.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/tests/language/argument_definition_test.dart
diff --git a/dart/tests/language/argument_definition_test.dart b/dart/tests/language/argument_definition_test.dart
index d2d8ae6e4068fc5e66dccd45cace663f03e66b63..a128100452107912208a95d8bf072315f3e60645 100644
--- a/dart/tests/language/argument_definition_test.dart
+++ b/dart/tests/language/argument_definition_test.dart
@@ -3,7 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program for testing argument definition test.
-int test(int a, [int b, int c]) {
+int test(int a, [int b = 2, int c = 3]) {
int result = 0;
?b;
?result; /// 01: compile-time error
@@ -17,10 +17,16 @@ int test(int a, [int b, int c]) {
var b; ?b; /// 02: compile-time error
result += 3;
}
+ if ((!?a?!?b:!?c) == (?a??b:?c)) {
+ result += 200;
+ }
+ if (!?a?!?b:!?c == ?a??b:?c) {
+ result += 400;
+ }
return result;
}
-closure_test(int a, [int b, int c]) {
+closure_test(int a, [int b = 2, int c = 3]) {
var x = 0;
return () {
int result = 0;
@@ -37,6 +43,14 @@ closure_test(int a, [int b, int c]) {
var b; ?b; /// 05: compile-time error
result += 3;
}
+ // Equivalent to: (!?c) == ?b.
+ if ((!?a?!?b:!?c) == (?a??b:?c)) {
+ result += 200;
+ }
+ // Equivalent to: (!?c) ? ?b : ?c.
+ if (!?a?!?b:!?c == ?a??b:?c) {
+ result += 400;
+ }
return result;
};
}
@@ -45,13 +59,13 @@ main() {
// Use a loop to test optimized version as well.
for (int i = 0; i < 1000; i++) {
Expect.equals(100, test(1));
- Expect.equals(120, test(1, 2));
- Expect.equals(123, test(1, 2, 3));
- Expect.equals(103, test(1, c:3));
+ Expect.equals(720, test(1, 2));
+ Expect.equals(523, test(1, 2, 3));
+ Expect.equals(703, test(1, c:3));
Expect.equals(100, closure_test(1)());
- Expect.equals(120, closure_test(1, 2)());
- Expect.equals(123, closure_test(1, 2, 3)());
- Expect.equals(103, closure_test(1, c:3)());
+ Expect.equals(720, closure_test(1, 2)());
+ Expect.equals(523, closure_test(1, 2, 3)());
+ Expect.equals(703, closure_test(1, c:3)());
}
}
regis 2012/08/31 14:44:50 Matthias wanted me to add this other test yesterda
ahe 2012/08/31 15:08:45 So that's the origin. I took it from Gilad's chat
« no previous file with comments | « no previous file | dart/tests/language/language_dart2js.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698