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

Side by Side Diff: frog/tests/leg/src/compiler_helper.dart

Issue 10250002: test rename overhaul: step 5 - frog and leg tests (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 7 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
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.
4 // Test constant folding.
5
6 #library("compiler_helper");
7
8 #import("dart:uri");
9 #import("../../../../lib/compiler/implementation/leg.dart", prefix: "leg");
10 #import("../../../../lib/compiler/implementation/elements/elements.dart", prefix : "lego");
11 #import("../../../../lib/compiler/implementation/ssa/ssa.dart", prefix: "ssa");
12 #import("parser_helper.dart");
13 #import("mock_compiler.dart");
14
15 String compile(String code, [String entry = 'main']) {
16 MockCompiler compiler = new MockCompiler();
17 compiler.parseScript(code);
18 lego.Element element = compiler.mainApp.find(buildSourceString(entry));
19 if (element === null) return null;
20 String generated = compiler.compile(new leg.WorkItem.toCompile(element));
21 return generated;
22 }
23
24 String compileAll(String code) {
25 MockCompiler compiler = new MockCompiler();
26 Uri uri = new Uri(scheme: 'source');
27 compiler.sources[uri.toString()] = code;
28 compiler.runCompiler(uri);
29 return compiler.assembledCode;
30 }
31
32 String anyIdentifier = "[a-zA-Z][a-zA-Z0-9]*";
33
34 String getIntTypeCheck(String variable) {
35 return "\\($variable !== \\($variable \\| 0\\)\\)";
36 }
37
38 String getNumberTypeCheck(String variable) {
39 return "\\(typeof $variable !== 'number'\\)";
40 }
41
42 bool checkNumberOfMatches(Iterator it, int nb) {
43 for (int i = 0; i < nb; i++) {
44 Expect.isTrue(it.hasNext());
45 it.next();
46 }
47 Expect.isFalse(it.hasNext());
48 }
49
50 void compileAndMatch(String code, String entry, RegExp regexp) {
51 String generated = compile(code, entry);
52 Expect.isTrue(regexp.hasMatch(generated),
53 '"$generated" does not match /$regexp/');
54 }
55
56 void compileAndDoNotMatch(String code, String entry, RegExp regexp) {
57 String generated = compile(code, entry);
58 Expect.isFalse(regexp.hasMatch(generated),
59 '"$generated" has a match in /$regexp/');
60 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698