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

Unified Diff: tests/corelib/apply2_test.dart

Issue 1024563003: Clean up apply2-test. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Added case to apply2_test Created 5 years, 9 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/corelib/apply2_test.dart
diff --git a/tests/corelib/apply2_test.dart b/tests/corelib/apply2_test.dart
index 021f415edca7eac78179ae6000ddadeb18f92724..5270949b32d2f2aee22a7d946561e6d978aac1ce 100644
--- a/tests/corelib/apply2_test.dart
+++ b/tests/corelib/apply2_test.dart
@@ -3,23 +3,14 @@
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
-import "symbol_map_helper.dart";
-apply(Function function, ArgumentDescriptor args) {
- return Function.apply(
- function, args.positionalArguments,
- symbolMapToStringMap(args.namedArguments));
+apply(Function function, List positional, Map<Symbol, dynamic> named) {
+ return Function.apply(function, positional, named);
}
-class ArgumentDescriptor {
- final List positionalArguments;
- final Map<String, dynamic> namedArguments;
-
- ArgumentDescriptor(this.positionalArguments, this.namedArguments);
-}
-
-void throwsNSME(function) {
- Expect.throws(function, (e) => e is NoSuchMethodError);
+void throwsNSME(function, positional, named) {
+ Expect.throws(() => apply(function, positional, named),
+ (e) => e is NoSuchMethodError);
}
main() {
@@ -30,76 +21,76 @@ main() {
var c5 = ({a: 1, b: 2}) => 'c5 $a $b';
var c6 = ({b: 1, a: 2}) => 'c6 $a $b';
var c7 = (x, {b: 1, a: 2}) => 'c7 $x $a $b';
+ var c8 = (x, y, [a = 2, b = 3]) => 'c8 $x $y $a $b';
- Expect.equals('c1', apply(c1, new ArgumentDescriptor(null, null)));
- Expect.equals('c1', apply(c1, new ArgumentDescriptor([], null)));
- Expect.equals('c1', apply(c1, new ArgumentDescriptor([], {})));
- Expect.equals('c1', apply(c1, new ArgumentDescriptor(null, {})));
- throwsNSME(() => apply(c1, new ArgumentDescriptor([1], null)));
- throwsNSME(() => apply(c1, new ArgumentDescriptor([1], {'a': 2})));
- throwsNSME(() => apply(c1, new ArgumentDescriptor(null, {'a': 2})));
+ Expect.equals('c1', apply(c1, null, null));
+ Expect.equals('c1', apply(c1, [], null));
+ Expect.equals('c1', apply(c1, [], {}));
+ Expect.equals('c1', apply(c1, null, {}));
+ throwsNSME(c1, [1], null);
+ throwsNSME(c1, [1], {#a: 2});
+ throwsNSME(c1, null, {#a: 2});
- Expect.equals('c2 1', apply(c2, new ArgumentDescriptor([1], null)));
- Expect.equals('c2 1', apply(c2, new ArgumentDescriptor([1], {})));
- throwsNSME(() => apply(c2, new ArgumentDescriptor(null, null)));
- throwsNSME(() => apply(c2, new ArgumentDescriptor([], null)));
- throwsNSME(() => apply(c2, new ArgumentDescriptor(null, {})));
- throwsNSME(() => apply(c2, new ArgumentDescriptor(null, {'a': 1})));
+ Expect.equals('c2 1', apply(c2, [1], null));
+ Expect.equals('c2 1', apply(c2, [1], {}));
+ throwsNSME(c2, null, null);
+ throwsNSME(c2, [], null);
+ throwsNSME(c2, null, {});
+ throwsNSME(c2, null, {#a: 1});
+ throwsNSME(c2, [2], {#a: 1});
- Expect.equals('c3 1', apply(c3, new ArgumentDescriptor([], null)));
- Expect.equals('c3 2', apply(c3, new ArgumentDescriptor([2], {})));
- throwsNSME(() => apply(c3, new ArgumentDescriptor([1, 2], null)));
- throwsNSME(() => apply(c3, new ArgumentDescriptor(null, {'a': 1})));
+ Expect.equals('c3 1', apply(c3, null, null));
+ Expect.equals('c3 1', apply(c3, [], null));
+ Expect.equals('c3 2', apply(c3, [2], {}));
+ throwsNSME(c3, [1, 2], null);
+ throwsNSME(c3, null, {#a: 1});
- Expect.equals('c4 1', apply(c4, new ArgumentDescriptor([], null)));
- Expect.equals('c4 2', apply(c4, new ArgumentDescriptor([], {'a': 2})));
- Expect.equals('c4 1', apply(c4, new ArgumentDescriptor(null, null)));
- Expect.equals('c4 1', apply(c4, new ArgumentDescriptor([], {})));
- throwsNSME(() => apply(c4, new ArgumentDescriptor([1], {'a': 1})));
- throwsNSME(() => apply(c4, new ArgumentDescriptor([1], {})));
- throwsNSME(() => apply(c4, new ArgumentDescriptor([], {'a': 1, 'b': 2})));
+ Expect.equals('c4 1', apply(c4, [], null));
+ Expect.equals('c4 2', apply(c4, [], {#a: 2}));
+ Expect.equals('c4 1', apply(c4, null, null));
+ Expect.equals('c4 1', apply(c4, [], {}));
+ throwsNSME(c4, [1], {#a: 1});
+ throwsNSME(c4, [1], {});
+ throwsNSME(c4, [], {#a: 1, #b: 2});
- Expect.equals('c5 1 2', apply(c5, new ArgumentDescriptor([], null)));
- Expect.equals('c5 3 2', apply(c5, new ArgumentDescriptor([], {'a': 3})));
- Expect.equals('c5 1 2', apply(c5, new ArgumentDescriptor(null, null)));
- Expect.equals('c5 1 2', apply(c5, new ArgumentDescriptor([], {})));
- Expect.equals('c5 3 4',
- apply(c5, new ArgumentDescriptor([], {'a': 3, 'b': 4})));
- Expect.equals('c5 4 3',
- apply(c5, new ArgumentDescriptor([], {'b': 3, 'a': 4})));
- Expect.equals('c5 1 3',
- apply(c5, new ArgumentDescriptor([], {'b': 3})));
- throwsNSME(() => apply(c5, new ArgumentDescriptor([1], {'a': 1})));
- throwsNSME(() => apply(c5, new ArgumentDescriptor([1], {})));
- throwsNSME(() =>
- apply(c5, new ArgumentDescriptor([], {'a': 1, 'b': 2, 'c': 3})));
+ Expect.equals('c5 1 2', apply(c5, [], null));
+ Expect.equals('c5 3 2', apply(c5, [], {#a: 3}));
+ Expect.equals('c5 1 2', apply(c5, null, null));
+ Expect.equals('c5 1 2', apply(c5, [], {}));
+ Expect.equals('c5 3 4', apply(c5, [], {#a: 3, #b: 4}));
+ Expect.equals('c5 4 3', apply(c5, [], {#b: 3, #a: 4}));
+ Expect.equals('c5 1 3', apply(c5, [], {#b: 3}));
+ throwsNSME(c5, [1], {#a: 1});
+ throwsNSME(c5, [1], {});
+ throwsNSME(c5, [], {#a: 1, #b: 2, #c: 3});
- Expect.equals('c6 2 1', apply(c6, new ArgumentDescriptor([], null)));
- Expect.equals('c6 3 1', apply(c6, new ArgumentDescriptor([], {'a': 3})));
- Expect.equals('c6 2 1', apply(c6, new ArgumentDescriptor(null, null)));
- Expect.equals('c6 2 1', apply(c6, new ArgumentDescriptor([], {})));
- Expect.equals('c6 3 4',
- apply(c6, new ArgumentDescriptor([], {'a': 3, 'b': 4})));
- Expect.equals('c6 4 3',
- apply(c6, new ArgumentDescriptor([], {'b': 3, 'a': 4})));
- Expect.equals('c6 2 3',
- apply(c6, new ArgumentDescriptor([], {'b': 3})));
- throwsNSME(() => apply(c6, new ArgumentDescriptor([1], {'a': 1})));
- throwsNSME(() => apply(c6, new ArgumentDescriptor([1], {})));
- throwsNSME(() =>
- apply(c6, new ArgumentDescriptor([], {'a': 1, 'b': 2, 'c': 3})));
+ Expect.equals('c6 2 1', apply(c6, [], null));
+ Expect.equals('c6 3 1', apply(c6, [], {#a: 3}));
+ Expect.equals('c6 2 1', apply(c6, null, null));
+ Expect.equals('c6 2 1', apply(c6, [], {}));
+ Expect.equals('c6 3 4', apply(c6, [], {#a: 3, #b: 4}));
+ Expect.equals('c6 4 3', apply(c6, [], {#b: 3, #a: 4}));
+ Expect.equals('c6 2 3', apply(c6, [], {#b: 3}));
+ throwsNSME(c6, [1], {#a: 1});
+ throwsNSME(c6, [1], {});
+ throwsNSME(c6, [], {#a: 1, #b: 2, #c: 3});
- Expect.equals('c7 7 2 1', apply(c7, new ArgumentDescriptor([7], null)));
- Expect.equals('c7 7 3 1', apply(c7, new ArgumentDescriptor([7], {'a': 3})));
- Expect.equals('c7 7 2 1', apply(c7, new ArgumentDescriptor([7], {})));
- Expect.equals('c7 7 3 4',
- apply(c7, new ArgumentDescriptor([7], {'a': 3, 'b': 4})));
- Expect.equals('c7 7 4 3',
- apply(c7, new ArgumentDescriptor([7], {'b': 3, 'a': 4})));
- Expect.equals('c7 7 2 3',
- apply(c7, new ArgumentDescriptor([7], {'b': 3})));
- throwsNSME(() => apply(c7, new ArgumentDescriptor([], {'a': 1})));
- throwsNSME(() => apply(c7, new ArgumentDescriptor([], {})));
- throwsNSME(() =>
- apply(c7, new ArgumentDescriptor([7], {'a': 1, 'b': 2, 'c': 3})));
+ Expect.equals('c7 7 2 1', apply(c7, [7], null));
+ Expect.equals('c7 7 3 1', apply(c7, [7], {#a: 3}));
+ Expect.equals('c7 7 2 1', apply(c7, [7], {}));
+ Expect.equals('c7 7 3 4', apply(c7, [7], {#a: 3, #b: 4}));
+ Expect.equals('c7 7 4 3', apply(c7, [7], {#b: 3, #a: 4}));
+ Expect.equals('c7 7 2 3', apply(c7, [7], {#b: 3}));
+ throwsNSME(c7, [], {#a: 1});
+ throwsNSME(c7, [], {});
+ throwsNSME(c7, [7], {#a: 1, #b: 2, #c: 3});
+
+ Expect.equals('c8 7 8 2 3', apply(c8, [7, 8], null));
+ Expect.equals('c8 7 8 2 3', apply(c8, [7, 8], {}));
+ Expect.equals('c8 7 8 3 3', apply(c8, [7, 8, 3], null));
+ Expect.equals('c8 7 8 3 4', apply(c8, [7, 8, 3, 4], null));
+ throwsNSME(c8, [], null);
+ throwsNSME(c8, [], {});
+ throwsNSME(c8, [1], null);
+ throwsNSME(c8, [7, 8, 9, 10, 11], null);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698