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

Side by Side Diff: tests/lib_strong/html/js_typed_interop_default_arg_test.dart

Issue 2768073002: Format all multitests (Closed)
Patch Set: Created 3 years, 9 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 @JS() 5 @JS()
6 library js_typed_interop_test; 6 library js_typed_interop_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:expect/minitest.dart'; 11 import 'package:expect/minitest.dart';
12 12
13 _injectJs() { 13 _injectJs() {
14 document.body.append(new ScriptElement() 14 document.body.append(new ScriptElement()
15 ..type = 'text/javascript' 15 ..type = 'text/javascript'
16 ..innerHtml = r""" 16 ..innerHtml = r"""
17 var Foo = { 17 var Foo = {
18 get42: function(b) { return arguments.length >= 1 ? b : 42; }, 18 get42: function(b) { return arguments.length >= 1 ? b : 42; },
19 get43: function(b) { return arguments.length >= 1 ? b : 43; } 19 get43: function(b) { return arguments.length >= 1 ? b : 43; }
20 }; 20 };
21 """); 21 """);
22 } 22 }
23 23
24 @JS() 24 @JS()
25 class Foo { 25 class Foo {
26 // Note: it's invalid to provide a default value. 26 // Note: it's invalid to provide a default value.
27 external static num get42([num b 27 external static num get42([num b
28 = 3 // //# default_value: compile-time error 28 = 3 // //# default_value: compile-time error
29 ]); 29 ]);
30 external static num get43([num b]); 30 external static num get43([num b]);
31 } 31 }
32 32
33 main() { 33 main() {
34 _injectJs(); 34 _injectJs();
35 35
36 test('call directly from dart', () { 36 test('call directly from dart', () {
37 expect(Foo.get42(2), 2); 37 expect(Foo.get42(2), 2);
38 expect(Foo.get42(), 42); 38 expect(Foo.get42(), 42);
39 }); 39 });
40 40
41 test('call tearoff from dart with arg', () { 41 test('call tearoff from dart with arg', () {
42 var f = Foo.get42; 42 var f = Foo.get42;
43 expect(f(2), 2); //# explicit_argument: ok 43 expect(f(2), 2); //# explicit_argument: ok
44 }); 44 });
45 45
46 test('call tearoff from dart with default', () { 46 test('call tearoff from dart with default', () {
47 var f = Foo.get42; 47 var f = Foo.get42;
48 // Note: today both SSA and CPS remove the extra argument on static calls, 48 // Note: today both SSA and CPS remove the extra argument on static calls,
49 // but they fail to do so on tearoffs. 49 // but they fail to do so on tearoffs.
50 expect(f(), 3); //# default_value: continued 50 expect(f(), 3); //# default_value: continued
51 51
52 f = Foo.get43; 52 f = Foo.get43;
53 expect(f(), 43); 53 expect(f(), 43);
54 }); 54 });
55 } 55 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698