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

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

Issue 11146013: Fix JS minifier to lift var declarations within functions. Still disabled. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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 side-by-side diff with in-line comments
Download patch
Index: tests/compiler/dart2js/compiler_helper.dart
diff --git a/tests/compiler/dart2js/compiler_helper.dart b/tests/compiler/dart2js/compiler_helper.dart
index 057a3aaa8ff997321e7622101dbeb53cfa2764f1..6606697eccba06267434881efa22dc75d84dcc30 100644
--- a/tests/compiler/dart2js/compiler_helper.dart
+++ b/tests/compiler/dart2js/compiler_helper.dart
@@ -68,11 +68,11 @@ lego.Element findElement(compiler, String name) {
String anyIdentifier = "[a-zA-Z][a-zA-Z0-9]*";
String getIntTypeCheck(String variable) {
- return "\\($variable !== \\($variable \\| 0\\)\\)";
+ return "\\($variable ?!== ?\\($variable ?\\| ?0\\)\\)";
}
String getNumberTypeCheck(String variable) {
- return "\\(typeof $variable !== 'number'\\)";
+ return "\\(typeof $variable ?!== ?'number'\\)";
}
bool checkNumberOfMatches(Iterator it, int nb) {
@@ -96,3 +96,28 @@ void compileAndDoNotMatch(String code, String entry, RegExp regexp) {
}
int length(Link link) => link.isEmpty() ? 0 : length(link.tail) + 1;
+
+// Does a compile and then a match where every 'x' is replaced by something
+// that matches any variable, and every space is optional.
+void compileAndMatchFuzzy(String code, String entry, String regexp) {
+ compileAndMatchFuzzyHelper(code, entry, regexp, true);
+}
+
+void compileAndDoNotMatchFuzzy(String code, String entry, String regexp) {
+ compileAndMatchFuzzyHelper(code, entry, regexp, false);
+}
+
+void compileAndMatchFuzzyHelper(
+ String code, String entry, String regexp, bool shouldMatch) {
+ String generated = compile(code, entry);
+ final xRe = new RegExp('\\bx\\b');
+ regexp = regexp.replaceAll(xRe, '(?:$anyIdentifier)');
+ final spaceRe = new RegExp('\\s+');
+ regexp = regexp.replaceAll(spaceRe, '(?:\\s*)');
+ if (shouldMatch) {
+ Expect.isTrue(new RegExp(regexp).hasMatch(generated));
+ } else {
+ Expect.isFalse(new RegExp(regexp).hasMatch(generated));
+ }
+}
+

Powered by Google App Engine
This is Rietveld 408576698