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

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

Issue 1537663002: dart2js: Initial implementation of inlining. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Rebaseline test expectations and fix a bug (typo). Created 4 years, 12 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 // Tests for constant folding and lowering String.codeUnitAt. 5 // Tests for constant folding and lowering String.codeUnitAt.
6 6
7 library basic_tests; 7 library basic_tests;
8 8
9 import 'js_backend_cps_ir.dart'; 9 import 'js_backend_cps_ir.dart';
10 10
11 const List<TestEntry> tests = const [ 11 const List<TestEntry> tests = const [
12 12
13 // Constant folding. 13 // Constant folding.
14 const TestEntry(r""" 14 const TestEntry(r"""
15 main() { 15 main() {
16 print('A'.codeUnitAt(0)); 16 print('A'.codeUnitAt(0));
17 }""",r""" 17 }""",r"""
18 function() { 18 function() {
19 P.print(65); 19 var v0 = H.S(65);
20 if (typeof dartPrint == "function")
21 dartPrint(v0);
22 else if (typeof console == "object" && typeof console.log != "undefined")
23 console.log(v0);
24 else if (!(typeof window == "object")) {
25 if (!(typeof print == "function"))
26 throw "Unable to print message: " + String(v0);
27 print(v0);
28 }
20 }"""), 29 }"""),
21 30
22 31
23 // Bounds checking. 32 // Bounds checking.
24 const TestEntry.forMethod('function(foo)', 33 const TestEntry.forMethod('function(foo)',
25 r""" 34 r"""
26 foo(s) { 35 foo(s) {
27 var sum = 0; 36 var sum = 0;
28 for (int i = 0; i < s.length; i++) sum += s.codeUnitAt(i); 37 for (int i = 0; i < s.length; i++) sum += s.codeUnitAt(i);
29 return sum; 38 return sum;
30 } 39 }
31 main() { 40 main() {
32 print(foo('ABC')); 41 print(foo('ABC'));
33 print(foo('Hello')); 42 print(foo('Hello'));
34 }""",r""" 43 }""",r"""
35 function(s) { 44 function(s) {
36 var v0 = s.length, sum = 0, i = 0; 45 var v0 = s.length, sum = 0, i = 0;
37 for (; i < v0; sum = sum + s.charCodeAt(i), i = i + 1) 46 for (; i < v0; sum = sum + s.charCodeAt(i), i = i + 1)
38 ; 47 ;
39 return sum; 48 return sum;
40 }"""), 49 }"""),
41 ]; 50 ];
42 51
43 52
44 void main() { 53 void main() {
45 runTests(tests); 54 runTests(tests);
46 } 55 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698