| 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'; |
| 11 import 'package:unittest/unittest.dart'; | 11 import 'package:minitest/minitest.dart'; |
| 12 import 'package:unittest/html_config.dart'; | |
| 13 import 'package:unittest/html_individual_config.dart'; | |
| 14 | 12 |
| 15 _injectJs() { | 13 _injectJs() { |
| 16 document.body.append(new ScriptElement() | 14 document.body.append(new ScriptElement() |
| 17 ..type = 'text/javascript' | 15 ..type = 'text/javascript' |
| 18 ..innerHtml = r""" | 16 ..innerHtml = r""" |
| 19 var bar = { }; | 17 var bar = { }; |
| 20 | 18 |
| 21 bar.instanceMember = function() { | 19 bar.instanceMember = function() { |
| 22 if (this !== bar) { | 20 if (this !== bar) { |
| 23 throw 'Unexpected this!'; | 21 throw 'Unexpected this!'; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 abstract class Foo { | 54 abstract class Foo { |
| 57 external Bar get bar; | 55 external Bar get bar; |
| 58 } | 56 } |
| 59 | 57 |
| 60 @JS() | 58 @JS() |
| 61 external Foo get foo; | 59 external Foo get foo; |
| 62 | 60 |
| 63 main() { | 61 main() { |
| 64 _injectJs(); | 62 _injectJs(); |
| 65 | 63 |
| 66 useHtmlIndividualConfiguration(); | |
| 67 | |
| 68 group('call getter as function', () { | 64 group('call getter as function', () { |
| 69 test('member function', () { | 65 test('member function', () { |
| 70 expect(foo.bar.instanceMember(), equals(0)); | 66 expect(foo.bar.instanceMember(), equals(0)); |
| 71 expect(foo.bar.instanceMember(0), equals(1)); | 67 expect(foo.bar.instanceMember(0), equals(1)); |
| 72 expect(foo.bar.instanceMember(0,0), equals(2)); | 68 expect(foo.bar.instanceMember(0,0), equals(2)); |
| 73 expect(foo.bar.instanceMember(0,0,0,0,0,0), equals(6)); | 69 expect(foo.bar.instanceMember(0,0,0,0,0,0), equals(6)); |
| 74 var instanceMember = foo.bar.instanceMember; | 70 var instanceMember = foo.bar.instanceMember; |
| 75 expect(() => instanceMember(), throws); | 71 expect(() => instanceMember(), throws); |
| 76 expect(() => instanceMember(0), throws); | 72 expect(() => instanceMember(0), throws); |
| 77 expect(() => instanceMember(0,0), throws); | 73 expect(() => instanceMember(0,0), throws); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 100 expect(dynamicStatic(0), equals(1)); | 96 expect(dynamicStatic(0), equals(1)); |
| 101 expect(dynamicStatic(0,0), equals(2)); | 97 expect(dynamicStatic(0,0), equals(2)); |
| 102 expect(dynamicStatic(0,0,0,0,0,0), equals(6)); | 98 expect(dynamicStatic(0,0,0,0,0,0), equals(6)); |
| 103 }); | 99 }); |
| 104 | 100 |
| 105 test('typedef function', () { | 101 test('typedef function', () { |
| 106 expect(foo.bar.add(4,5), equals(9)); | 102 expect(foo.bar.add(4,5), equals(9)); |
| 107 }); | 103 }); |
| 108 }); | 104 }); |
| 109 } | 105 } |
| OLD | NEW |