| Index: tests/html/js_dart_to_string_test.dart
|
| diff --git a/tests/html/js_dart_to_string_test.dart b/tests/html/js_dart_to_string_test.dart
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..f702d6b978dcd3941811f23d3df5d237065ba314
|
| --- /dev/null
|
| +++ b/tests/html/js_dart_to_string_test.dart
|
| @@ -0,0 +1,46 @@
|
| +// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
|
| +// for details. All rights reserved. Use of this source code is governed by a
|
| +// BSD-style license that can be found in the LICENSE file.
|
| +
|
| +@Js()
|
| +library js_typed_interop_test;
|
| +
|
| +import 'dart:html';
|
| +
|
| +import 'package:js/js.dart';
|
| +import 'package:unittest/unittest.dart';
|
| +import 'package:unittest/html_config.dart';
|
| +
|
| +_injectJs() {
|
| + document.body.append(new ScriptElement()
|
| + ..type = 'text/javascript'
|
| + ..innerHtml = r"""
|
| +
|
| + function jsToStringViaCoercion(a) {
|
| + return a + '';
|
| + };
|
| +""");
|
| +}
|
| +
|
| +@Js()
|
| +external String jsToStringViaCoercion(obj);
|
| +
|
| +class ExampleClassWithCustomToString {
|
| + var x;
|
| + ExampleClassWithCustomToString(this.x);
|
| + String toString() => "#$x#";
|
| +}
|
| +
|
| +main() {
|
| + _injectJs();
|
| +
|
| + useHtmlConfiguration();
|
| +
|
| + group('toString', () {
|
| + test('custom dart', () {
|
| + var x = new ExampleClassWithCustomToString("fooBar");
|
| + expect(jsToStringViaCoercion(x), equals("#fooBar#"));
|
| + expect(jsToStringViaCoercion({'a' : 1, 'b': 2}), equals("{a: 1, b: 2}"));
|
| + });
|
| + });
|
| +}
|
|
|