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

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

Issue 2345083003: dart2js: run dartfmt on tests (Closed)
Patch Set: revert another multipart test Created 4 years, 3 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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:_js_helper"; 5 import "dart:_js_helper";
6 import "package:expect/expect.dart"; 6 import "package:expect/expect.dart";
7 7
8 // Test that hidden native exception classes can be marked as existing. 8 // Test that hidden native exception classes can be marked as existing.
9 // 9 //
10 // To infer which native hidden types exist, we need 10 // To infer which native hidden types exist, we need
11 // (1) return types of native methods and getters 11 // (1) return types of native methods and getters
12 // (2) argument types of callbacks 12 // (2) argument types of callbacks
13 // (3) exceptions thrown by the operation. 13 // (3) exceptions thrown by the operation.
14 // 14 //
15 // (1) and (2) can be achieved by having nicely typed native methods, but there 15 // (1) and (2) can be achieved by having nicely typed native methods, but there
16 // is no place in the Dart language to communicate (3). So we use the following 16 // is no place in the Dart language to communicate (3). So we use the following
17 // fake body technique. 17 // fake body technique.
18 18
19
20 // The exception type. 19 // The exception type.
21 @Native("E") 20 @Native("E")
22 class E { 21 class E {
23 E._used() native; // Bogus native constructor, called only from fake body. 22 E._used() native ; // Bogus native constructor, called only from fake body.
24 23
25 final int code; 24 final int code;
26 } 25 }
27 26
28 // Type with exception-throwing methods. 27 // Type with exception-throwing methods.
29 @Native("A") 28 @Native("A")
30 class A { 29 class A {
31 // Exception class E is created. 30 // Exception class E is created.
32 @Creates("E") 31 @Creates("E")
33 @Returns('int') 32 @Returns('int')
34 op(int x) native; 33 op(int x) native ;
35 } 34 }
36 35
37 // This class is here just so that a dynamic context is polymorphic. 36 // This class is here just so that a dynamic context is polymorphic.
38 class B { 37 class B {
39 int get code => 666; 38 int get code => 666;
40 op(String x) => 123; 39 op(String x) => 123;
41 } 40 }
42 41
43 makeA() native; 42 makeA() native ;
44 43
45 void setup1() native """ 44 void setup1() native """
46 // Ensure we are not relying on global names 'A' and 'E'. 45 // Ensure we are not relying on global names 'A' and 'E'.
47 A = null; 46 A = null;
48 E = null; 47 E = null;
49 """; 48 """;
50 49
51 void setup2() native """ 50 void setup2() native """
52 // This code is all inside 'setup2' and so not accesible from the global scope. 51 // This code is all inside 'setup2' and so not accesible from the global scope.
53 function E(x){ this.code = x; } 52 function E(x){ this.code = x; }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 threw = false; 94 threw = false;
96 try { 95 try {
97 var x = aa.op(51); 96 var x = aa.op(51);
98 } on E catch (e) { 97 } on E catch (e) {
99 threw = true; 98 threw = true;
100 Expect.equals(100, e.code); 99 Expect.equals(100, e.code);
101 Expect.isTrue(e is E); 100 Expect.isTrue(e is E);
102 } 101 }
103 Expect.isTrue(threw); 102 Expect.isTrue(threw);
104 } 103 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698