OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
6 import "symbol_map_helper.dart"; | 6 import "symbol_map_helper.dart"; |
7 | 7 |
8 apply(Function function, ArgumentDescriptor args) { | 8 apply(Function function, ArgumentDescriptor args) { |
9 return Function.apply( | 9 return Function.apply( |
10 function, args.positionalArguments, | 10 function, args.positionalArguments, |
(...skipping 11 matching lines...) Expand all Loading... |
22 Expect.throws(function, (e) => e is NoSuchMethodError); | 22 Expect.throws(function, (e) => e is NoSuchMethodError); |
23 } | 23 } |
24 | 24 |
25 main() { | 25 main() { |
26 var c1 = () => 'c1'; | 26 var c1 = () => 'c1'; |
27 var c2 = (a) => 'c2 $a'; | 27 var c2 = (a) => 'c2 $a'; |
28 var c3 = ([a = 1]) => 'c3 $a'; | 28 var c3 = ([a = 1]) => 'c3 $a'; |
29 var c4 = ({a: 1}) => 'c4 $a'; | 29 var c4 = ({a: 1}) => 'c4 $a'; |
30 var c5 = ({a: 1, b: 2}) => 'c5 $a $b'; | 30 var c5 = ({a: 1, b: 2}) => 'c5 $a $b'; |
31 var c6 = ({b: 1, a: 2}) => 'c6 $a $b'; | 31 var c6 = ({b: 1, a: 2}) => 'c6 $a $b'; |
| 32 var c7 = (x, {b: 1, a: 2}) => 'c7 $x $a $b'; |
32 | 33 |
33 Expect.equals('c1', apply(c1, new ArgumentDescriptor(null, null))); | 34 Expect.equals('c1', apply(c1, new ArgumentDescriptor(null, null))); |
34 Expect.equals('c1', apply(c1, new ArgumentDescriptor([], null))); | 35 Expect.equals('c1', apply(c1, new ArgumentDescriptor([], null))); |
35 Expect.equals('c1', apply(c1, new ArgumentDescriptor([], {}))); | 36 Expect.equals('c1', apply(c1, new ArgumentDescriptor([], {}))); |
36 Expect.equals('c1', apply(c1, new ArgumentDescriptor(null, {}))); | 37 Expect.equals('c1', apply(c1, new ArgumentDescriptor(null, {}))); |
37 throwsNSME(() => apply(c1, new ArgumentDescriptor([1], null))); | 38 throwsNSME(() => apply(c1, new ArgumentDescriptor([1], null))); |
38 throwsNSME(() => apply(c1, new ArgumentDescriptor([1], {'a': 2}))); | 39 throwsNSME(() => apply(c1, new ArgumentDescriptor([1], {'a': 2}))); |
39 throwsNSME(() => apply(c1, new ArgumentDescriptor(null, {'a': 2}))); | 40 throwsNSME(() => apply(c1, new ArgumentDescriptor(null, {'a': 2}))); |
40 | 41 |
41 Expect.equals('c2 1', apply(c2, new ArgumentDescriptor([1], null))); | 42 Expect.equals('c2 1', apply(c2, new ArgumentDescriptor([1], null))); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 Expect.equals('c6 3 4', | 81 Expect.equals('c6 3 4', |
81 apply(c6, new ArgumentDescriptor([], {'a': 3, 'b': 4}))); | 82 apply(c6, new ArgumentDescriptor([], {'a': 3, 'b': 4}))); |
82 Expect.equals('c6 4 3', | 83 Expect.equals('c6 4 3', |
83 apply(c6, new ArgumentDescriptor([], {'b': 3, 'a': 4}))); | 84 apply(c6, new ArgumentDescriptor([], {'b': 3, 'a': 4}))); |
84 Expect.equals('c6 2 3', | 85 Expect.equals('c6 2 3', |
85 apply(c6, new ArgumentDescriptor([], {'b': 3}))); | 86 apply(c6, new ArgumentDescriptor([], {'b': 3}))); |
86 throwsNSME(() => apply(c6, new ArgumentDescriptor([1], {'a': 1}))); | 87 throwsNSME(() => apply(c6, new ArgumentDescriptor([1], {'a': 1}))); |
87 throwsNSME(() => apply(c6, new ArgumentDescriptor([1], {}))); | 88 throwsNSME(() => apply(c6, new ArgumentDescriptor([1], {}))); |
88 throwsNSME(() => | 89 throwsNSME(() => |
89 apply(c6, new ArgumentDescriptor([], {'a': 1, 'b': 2, 'c': 3}))); | 90 apply(c6, new ArgumentDescriptor([], {'a': 1, 'b': 2, 'c': 3}))); |
| 91 |
| 92 Expect.equals('c7 7 2 1', apply(c7, new ArgumentDescriptor([7], null))); |
| 93 Expect.equals('c7 7 3 1', apply(c7, new ArgumentDescriptor([7], {'a': 3}))); |
| 94 Expect.equals('c7 7 2 1', apply(c7, new ArgumentDescriptor([7], {}))); |
| 95 Expect.equals('c7 7 3 4', |
| 96 apply(c7, new ArgumentDescriptor([7], {'a': 3, 'b': 4}))); |
| 97 Expect.equals('c7 7 4 3', |
| 98 apply(c7, new ArgumentDescriptor([7], {'b': 3, 'a': 4}))); |
| 99 Expect.equals('c7 7 2 3', |
| 100 apply(c7, new ArgumentDescriptor([7], {'b': 3}))); |
| 101 throwsNSME(() => apply(c7, new ArgumentDescriptor([], {'a': 1}))); |
| 102 throwsNSME(() => apply(c7, new ArgumentDescriptor([], {}))); |
| 103 throwsNSME(() => |
| 104 apply(c7, new ArgumentDescriptor([7], {'a': 1, 'b': 2, 'c': 3}))); |
90 } | 105 } |
OLD | NEW |