OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 @JS() | 5 @JS() |
6 library js_function_getter_test; | 6 library js_function_getter_test; |
7 | 7 |
8 import 'dart:html'; | 8 import 'dart:html'; |
9 | 9 |
10 import 'package:js/js.dart'; | 10 import 'package:js/js.dart'; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 | 62 |
63 main() { | 63 main() { |
64 _injectJs(); | 64 _injectJs(); |
65 | 65 |
66 useHtmlIndividualConfiguration(); | 66 useHtmlIndividualConfiguration(); |
67 | 67 |
68 group('call getter as function', () { | 68 group('call getter as function', () { |
69 test('member function', () { | 69 test('member function', () { |
70 expect(foo.bar.instanceMember(), equals(0)); | 70 expect(foo.bar.instanceMember(), equals(0)); |
71 expect(foo.bar.instanceMember(0), equals(1)); | 71 expect(foo.bar.instanceMember(0), equals(1)); |
72 expect(foo.bar.instanceMember(0,0), equals(2)); | 72 expect(foo.bar.instanceMember(0, 0), equals(2)); |
73 expect(foo.bar.instanceMember(0,0,0,0,0,0), equals(6)); | 73 expect(foo.bar.instanceMember(0, 0, 0, 0, 0, 0), equals(6)); |
74 var instanceMember = foo.bar.instanceMember; | 74 var instanceMember = foo.bar.instanceMember; |
75 expect(() => instanceMember(), throws); | 75 expect(() => instanceMember(), throws); |
76 expect(() => instanceMember(0), throws); | 76 expect(() => instanceMember(0), throws); |
77 expect(() => instanceMember(0,0), throws); | 77 expect(() => instanceMember(0, 0), throws); |
78 expect(() => instanceMember(0,0,0,0,0,0), throws); | 78 expect(() => instanceMember(0, 0, 0, 0, 0, 0), throws); |
79 }); | 79 }); |
80 | 80 |
81 test('static function', () { | 81 test('static function', () { |
82 expect(foo.bar.staticMember(), equals(0)); | 82 expect(foo.bar.staticMember(), equals(0)); |
83 expect(foo.bar.staticMember(0), equals(2)); | 83 expect(foo.bar.staticMember(0), equals(2)); |
84 expect(foo.bar.staticMember(0,0), equals(4)); | 84 expect(foo.bar.staticMember(0, 0), equals(4)); |
85 expect(foo.bar.staticMember(0,0,0,0,0,0), equals(12)); | 85 expect(foo.bar.staticMember(0, 0, 0, 0, 0, 0), equals(12)); |
86 var staticMember = foo.bar.staticMember; | 86 var staticMember = foo.bar.staticMember; |
87 expect(staticMember(), equals(0)); | 87 expect(staticMember(), equals(0)); |
88 expect(staticMember(0), equals(2)); | 88 expect(staticMember(0), equals(2)); |
89 expect(staticMember(0,0), equals(4)); | 89 expect(staticMember(0, 0), equals(4)); |
90 expect(staticMember(0,0,0,0,0,0), equals(12)); | 90 expect(staticMember(0, 0, 0, 0, 0, 0), equals(12)); |
91 }); | 91 }); |
92 | 92 |
93 test('static dynamicStatic', () { | 93 test('static dynamicStatic', () { |
94 expect(foo.bar.dynamicStatic(), equals(0)); | 94 expect(foo.bar.dynamicStatic(), equals(0)); |
95 expect(foo.bar.dynamicStatic(0), equals(1)); | 95 expect(foo.bar.dynamicStatic(0), equals(1)); |
96 expect(foo.bar.dynamicStatic(0,0), equals(2)); | 96 expect(foo.bar.dynamicStatic(0, 0), equals(2)); |
97 expect(foo.bar.dynamicStatic(0,0,0,0,0,0), equals(6)); | 97 expect(foo.bar.dynamicStatic(0, 0, 0, 0, 0, 0), equals(6)); |
98 var dynamicStatic = foo.bar.dynamicStatic; | 98 var dynamicStatic = foo.bar.dynamicStatic; |
99 expect(dynamicStatic(), equals(0)); | 99 expect(dynamicStatic(), equals(0)); |
100 expect(dynamicStatic(0), equals(1)); | 100 expect(dynamicStatic(0), equals(1)); |
101 expect(dynamicStatic(0,0), equals(2)); | 101 expect(dynamicStatic(0, 0), equals(2)); |
102 expect(dynamicStatic(0,0,0,0,0,0), equals(6)); | 102 expect(dynamicStatic(0, 0, 0, 0, 0, 0), equals(6)); |
103 }); | 103 }); |
104 | 104 |
105 test('typedef function', () { | 105 test('typedef function', () { |
106 expect(foo.bar.add(4,5), equals(9)); | 106 expect(foo.bar.add(4, 5), equals(9)); |
107 }); | 107 }); |
108 }); | 108 }); |
109 } | 109 } |
OLD | NEW |