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

Side by Side Diff: pkg/dev_compiler/test/codegen/lib/html/js_typed_interop_default_arg_test.dart

Issue 2413073002: Start cleaning up the HTML tests. (Closed)
Patch Set: Unfork expect.dart. 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 @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:expect/expect.dart' show NoInline;
11 import 'package:js/js.dart'; 10 import 'package:js/js.dart';
12 import 'package:unittest/unittest.dart'; 11 import 'package:minitest/minitest.dart';
13 import 'package:unittest/html_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 Foo = { 17 var Foo = {
20 get42: function(b) { return arguments.length >= 1 ? b : 42; }, 18 get42: function(b) { return arguments.length >= 1 ? b : 42; },
21 get43: function(b) { return arguments.length >= 1 ? b : 43; } 19 get43: function(b) { return arguments.length >= 1 ? b : 43; }
22 }; 20 };
23 """); 21 """);
24 } 22 }
25 23
26 @JS() 24 @JS()
27 class Foo { 25 class Foo {
28 // Note: it's invalid to provide a default value. 26 // Note: it's invalid to provide a default value.
29 external static num get42([num b 27 external static num get42([num b
30 = 3 /// default_value: compile-time error 28 = 3 /// default_value: compile-time error
31 ]); 29 ]);
32 external static num get43([num b]); 30 external static num get43([num b]);
33 } 31 }
34 32
35 main() { 33 main() {
36 _injectJs(); 34 _injectJs();
37 useHtmlConfiguration();
38 35
39 test('call directly from dart', () { 36 test('call directly from dart', () {
40 expect(Foo.get42(2), 2); 37 expect(Foo.get42(2), 2);
41 expect(Foo.get42(), 42); 38 expect(Foo.get42(), 42);
42 }); 39 });
43 40
44 test('call tearoff from dart with arg', () { 41 test('call tearoff from dart with arg', () {
45 var f = Foo.get42; 42 var f = Foo.get42;
46 expect(f(2), 2); /// explicit_argument: ok 43 expect(f(2), 2); /// explicit_argument: ok
47 }); 44 });
48 45
49 test('call tearoff from dart with default', () { 46 test('call tearoff from dart with default', () {
50 var f = Foo.get42; 47 var f = Foo.get42;
51 // 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,
52 // but they fail to do so on tearoffs. 49 // but they fail to do so on tearoffs.
53 expect(f(), 3); /// default_value: continued 50 expect(f(), 3); /// default_value: continued
54 51
55 f = Foo.get43; 52 f = Foo.get43;
56 expect(f(), 43); 53 expect(f(), 43);
57 }); 54 });
58 } 55 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698