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

Unified Diff: tests/compiler/dart2js/string_escapes2_test.dart

Issue 930263002: dart2js: Avoid escaping in strings if it's not necessary. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Use charsets. Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/compiler/lib/src/js_backend/constant_emitter.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/compiler/dart2js/string_escapes2_test.dart
diff --git a/tests/compiler/dart2js/string_escapes2_test.dart b/tests/compiler/dart2js/string_escapes2_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..46e45aa64a80c7e7c286c52f9e5a5812c9e2d580
--- /dev/null
+++ b/tests/compiler/dart2js/string_escapes2_test.dart
@@ -0,0 +1,37 @@
+// 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.
+
+import 'dart:async';
+import 'package:async_helper/async_helper.dart';
+import 'package:expect/expect.dart';
+import 'compiler_helper.dart';
+
+// Test that the compiler doesn't escape too many characters.
+
+Future<String> compileExpression(String expression) {
+ var source = "foo() { return $expression; }";
+ return compile(source, entry: "foo");
+}
+
+Future runTest() {
+ return compileExpression(r"'Тест на Кирилица - great.\n"
+ r'Next "line".\u2028'
+ r'And another one.\u2029'
+ r"and the last one'")
+ .then((String generated) {
+ Expect.isTrue(
+ generated.contains(r'"Тест на Кирилица - great.\n'
+ r'Next \"line\".\u2028'
+ r'And another one.\u2029'
+ r'and the last one"') ||
+ generated.contains(r"'Тест на Кирилица - great.\n"
+ r'Next "line".\u2028'
+ r'And another one.\u2029'
+ r"and the last one'"));
+ });
+}
+
+main() {
+ asyncTest(runTest);
+}
« no previous file with comments | « pkg/compiler/lib/src/js_backend/constant_emitter.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698