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

Side by Side Diff: tests/html/js_dart_to_string_test.dart

Issue 1410403003: Switch Js to JS (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 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
« no previous file with comments | « tests/html/js_array_test.dart ('k') | tests/html/js_typed_interop_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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:unittest/unittest.dart'; 11 import 'package:unittest/unittest.dart';
12 import 'package:unittest/html_config.dart'; 12 import 'package:unittest/html_config.dart';
13 13
14 _injectJs() { 14 _injectJs() {
15 document.body.append(new ScriptElement() 15 document.body.append(new ScriptElement()
16 ..type = 'text/javascript' 16 ..type = 'text/javascript'
17 ..innerHtml = r""" 17 ..innerHtml = r"""
18 18
19 function jsToStringViaCoercion(a) { 19 function jsToStringViaCoercion(a) {
20 return a + ''; 20 return a + '';
21 }; 21 };
22 """); 22 """);
23 } 23 }
24 24
25 @Js() 25 @JS()
26 external String jsToStringViaCoercion(obj); 26 external String jsToStringViaCoercion(obj);
27 27
28 class ExampleClassWithCustomToString { 28 class ExampleClassWithCustomToString {
29 var x; 29 var x;
30 ExampleClassWithCustomToString(this.x); 30 ExampleClassWithCustomToString(this.x);
31 String toString() => "#$x#"; 31 String toString() => "#$x#";
32 } 32 }
33 33
34 main() { 34 main() {
35 _injectJs(); 35 _injectJs();
36 36
37 useHtmlConfiguration(); 37 useHtmlConfiguration();
38 38
39 group('toString', () { 39 group('toString', () {
40 test('custom dart', () { 40 test('custom dart', () {
41 var x = new ExampleClassWithCustomToString("fooBar"); 41 var x = new ExampleClassWithCustomToString("fooBar");
42 expect(jsToStringViaCoercion(x), equals("#fooBar#")); 42 expect(jsToStringViaCoercion(x), equals("#fooBar#"));
43 expect(jsToStringViaCoercion({'a' : 1, 'b': 2}), equals("{a: 1, b: 2}")); 43 expect(jsToStringViaCoercion({'a' : 1, 'b': 2}), equals("{a: 1, b: 2}"));
44 }); 44 });
45 }); 45 });
46 } 46 }
OLDNEW
« no previous file with comments | « tests/html/js_array_test.dart ('k') | tests/html/js_typed_interop_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698