OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | |
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. | |
4 | |
5 // Test for initialization of dispatchPropertyName. | |
6 | |
7 import "package:expect/expect.dart"; | |
8 import 'dart:_foreign_helper' show JS; | |
9 import 'dart:_js_helper' show Native; | |
10 | |
11 @Native("Foo") | |
12 class Foo { | |
13 String method(String x) native; | |
14 } | |
15 | |
16 makeFoo() native; | |
17 | |
18 void setup() native r""" | |
19 function Foo() {} | |
20 Foo.prototype.method = function(x) { return 'Foo ' + x; } | |
21 | |
22 self.makeFoo = function() { return new Foo(); } | |
23 """; | |
24 | |
25 | |
26 main() { | |
27 setup(); | |
28 | |
29 // If the dispatchPropertyName is uninitialized, it will be `undefined` or | |
30 // `null` instead oif teh secrst string or Symbol. These properties on | |
Johnni Winther
2016/09/22 08:15:55
'oif teh secrst' -> 'of the secret'
sra1
2016/09/22 16:43:14
Done.
| |
31 // `Object.prototype` will be retrieved by the lookup instead of `undefined` | |
32 // for the dispatch record. | |
33 JS('', r'self.Object.prototype["undefined"] = {}'); | |
34 JS('', r'self.Object.prototype["null"] = {}'); | |
35 Expect.equals('Foo A', makeFoo().method('A')); | |
36 | |
37 // Slightly different version that has malformed dispatch records. | |
38 JS('', r'self.Object.prototype["undefined"] = {p: false}'); | |
39 JS('', r'self.Object.prototype["null"] = {p: false}'); | |
40 Expect.equals('Foo B', makeFoo().method('B')); | |
41 } | |
OLD | NEW |