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

Side by Side Diff: tests/compiler/dart2js/js_spec_optimization_test.dart

Issue 2345083003: dart2js: run dartfmt on tests (Closed)
Patch Set: Created 4 years, 3 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 import 'dart:async'; 5 import 'dart:async';
6 import 'package:async_helper/async_helper.dart'; 6 import 'package:async_helper/async_helper.dart';
7 import 'package:expect/expect.dart'; 7 import 'package:expect/expect.dart';
8 import 'compiler_helper.dart'; 8 import 'compiler_helper.dart';
9 9
10 const String TEST_1 = r""" 10 const String TEST_1 = r"""
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 '#.toLowerCase()', s); 50 '#.toLowerCase()', s);
51 var s2 = JS('returns:String;depends:none;effects:none;throws:null(1)', 51 var s2 = JS('returns:String;depends:none;effects:none;throws:null(1)',
52 '#.toUpperCase()', s); 52 '#.toUpperCase()', s);
53 print(s2); 53 print(s2);
54 54
55 // absent: 'toLowerCase' - removed since s.toUpperCase() generates the same 55 // absent: 'toLowerCase' - removed since s.toUpperCase() generates the same
56 // noSuchMethod. 56 // noSuchMethod.
57 } 57 }
58 """; 58 """;
59 59
60
61 main() { 60 main() {
62 RegExp directivePattern = new RegExp( 61 RegExp directivePattern = new RegExp(
63 // \1 \2 \3 62 // \1 \2 \3
64 r'''// *(present|absent): (?:"([^"]*)"|'([^'']*)')''', 63 r'''// *(present|absent): (?:"([^"]*)"|'([^'']*)')''',
65 multiLine: true); 64 multiLine: true);
66 65
67 Future check(String test) { 66 Future check(String test) {
68 Uri uri = new Uri(scheme: 'dart', path: 'test'); 67 Uri uri = new Uri(scheme: 'dart', path: 'test');
69 var compiler = compilerFor(test, uri, expectedErrors: 0); 68 var compiler = compilerFor(test, uri, expectedErrors: 0);
70 return compiler.run(uri).then((_) { 69 return compiler.run(uri).then((_) {
71 var element = findElement(compiler, 'main'); 70 var element = findElement(compiler, 'main');
72 var backend = compiler.backend; 71 var backend = compiler.backend;
73 String generated = backend.getGeneratedCode(element); 72 String generated = backend.getGeneratedCode(element);
74 73
75 for (Match match in directivePattern.allMatches(test)) { 74 for (Match match in directivePattern.allMatches(test)) {
76 String directive = match.group(1); 75 String directive = match.group(1);
77 String pattern = match.groups([2, 3]).where((s) => s != null).single; 76 String pattern = match.groups([2, 3]).where((s) => s != null).single;
78 if (directive == 'present') { 77 if (directive == 'present') {
79 Expect.isTrue(generated.contains(pattern), 78 Expect.isTrue(generated.contains(pattern),
80 "Cannot find '$pattern' in:\n$generated"); 79 "Cannot find '$pattern' in:\n$generated");
81 } else { 80 } else {
82 assert(directive == 'absent'); 81 assert(directive == 'absent');
83 Expect.isFalse(generated.contains(pattern), 82 Expect.isFalse(generated.contains(pattern),
84 "Must not find '$pattern' in:\n$generated"); 83 "Must not find '$pattern' in:\n$generated");
85 } 84 }
86 } 85 }
87 }); 86 });
88 } 87 }
89 88
90 asyncTest(() => Future.wait([ 89 asyncTest(() => Future.wait([check(TEST_1), check(TEST_2), check(TEST_3),]));
Siggi Cherem (dart-lang) 2016/09/16 20:55:23 may want to delete trailing ,
Bob Nystrom 2016/09/16 21:16:03 This looks like you aren't running the latest dart
Harry Terkelsen 2016/09/16 21:44:04 I thought the trailing ',' was supposed to cause d
Harry Terkelsen 2016/09/16 21:44:04 Oops, I was running 0.2.4.
Harry Terkelsen 2016/09/16 21:50:28 I added the comma back, and it went one-per-line a
91 check(TEST_1),
92 check(TEST_2),
93 check(TEST_3),
94 ]));
95 } 90 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698