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

Side by Side Diff: tests/compiler/dart2js_native/event_loop_test.dart

Issue 2383273002: Revert "Add native_testing library to mock @Native classes" (Closed)
Patch Set: Created 4 years, 2 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 unified diff | Download patch
OLDNEW
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 import "dart:async"; 5 import "dart:async";
6 import "dart:_js_helper";
6 import "package:async_helper/async_helper.dart"; 7 import "package:async_helper/async_helper.dart";
7 import "native_testing.dart"; 8 import "package:expect/expect.dart";
8 9
9 typedef void Callback0(); 10 typedef void Callback0();
10 11
11 @Native("A") 12 @Native("A")
12 class A { 13 class A {
13 foo(Callback0 f) native ; 14 foo(Callback0 f) native ;
14 } 15 }
15 16
16 makeA() native ; 17 makeA() native ;
17 18
18 void setup() native r""" 19 void setup() native r"""
19 function A() {} 20 function A() {}
20 A.prototype.foo = function(f) { return f(); }; 21 A.prototype.foo = function(f) { return f(); };
21 makeA = function() { return new A; }; 22 makeA = function() { return new A; };
22 self.nativeConstructor(A);
23 """; 23 """;
24 24
25 main() { 25 main() {
26 nativeTesting();
27 setup(); 26 setup();
28 27
29 // Makes sure that we don't run the event-loop when we have a reentrant 28 // Makes sure that we don't run the event-loop when we have a reentrant
30 // call from JS to Dart code. 29 // call from JS to Dart code.
31 // We start by setting up a microtask that should only run after main has 30 // We start by setting up a microtask that should only run after main has
32 // finished. We then pass a closure into JavaScript. That closure is 31 // finished. We then pass a closure into JavaScript. That closure is
33 // immediately invoked. Dart2js had a bug, that it would start the event-loop 32 // immediately invoked. Dart2js had a bug, that it would start the event-loop
34 // at this moment (a JS->Dart transition), and execute the scheduled 33 // at this moment (a JS->Dart transition), and execute the scheduled
35 // microtask. 34 // microtask.
36 35
37 var events = []; 36 var events = [];
38 asyncStart(); 37 asyncStart();
39 var a = makeA(); 38 var a = makeA();
40 new Future.microtask(() { 39 new Future.microtask(() {
41 events.add("scheduleMicrotask"); 40 events.add("scheduleMicrotask");
42 }).whenComplete(asyncEnd); 41 }).whenComplete(asyncEnd);
43 42
44 Expect.equals(499, a.foo(() { 43 Expect.equals(499, a.foo(() {
45 events.add("closure to foo"); 44 events.add("closure to foo");
46 return 499; 45 return 499;
47 })); 46 }));
48 47
49 events.add("after native call"); 48 events.add("after native call");
50 Expect.listEquals(["closure to foo", "after native call"], events); 49 Expect.listEquals(["closure to foo", "after native call"], events);
51 } 50 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js_native/error_safeToString_test.dart ('k') | tests/compiler/dart2js_native/fake_thing_2_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698