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

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

Issue 16944004: Change how we deal with manual inlining of argument error and NSM when propagating types. This chan… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 6 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
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 "package:expect/expect.dart"; 5 import "package:expect/expect.dart";
6 import 'compiler_helper.dart'; 6 import 'compiler_helper.dart';
7 7
8 const String TEST_ONE = r""" 8 const String TEST_ONE = r"""
9 foo(a) { 9 foo(a) {
10 // Make sure there is a bailout version. 10 // Make sure there is a bailout version.
11 foo(a); 11 foo(a);
12 // This will make a one shot interceptor that will be optimized in 12 // This will make a one shot interceptor that will be optimized in
13 // the non-bailout version because we know a is a number. 13 // the non-bailout version because we know a is a number.
14 return (a + 42).toString; 14 return (a + 42).toString;
15 } 15 }
16 """; 16 """;
17 17
18 const String TEST_TWO = r""" 18 const String TEST_TWO = r"""
19 foo(a) { 19 foo(a) {
20 var myVariableName = a + 42; 20 var myVariableName = a.toString();
21 print(myVariableName); 21 print(myVariableName);
22 print(myVariableName); 22 print(myVariableName);
23 } 23 }
24 """; 24 """;
25 25
26 const String TEST_THREE = r""" 26 const String TEST_THREE = r"""
27 class A { 27 class A {
28 var length; 28 var length;
29 } 29 }
30 foo(a) { 30 foo(a) {
31 print([]); // Make sure the array class is instantiated. 31 print([]); // Make sure the array class is instantiated.
32 return new A().length + a.length; 32 return new A().length + a.length;
33 } 33 }
34 """; 34 """;
35 35
36 main() { 36 main() {
37 var generated = compile(TEST_ONE, entry: 'foo'); 37 var generated = compile(TEST_ONE, entry: 'foo');
38 // Check that the one shot interceptor got converted to a direct 38 // Check that the one shot interceptor got converted to a direct
39 // call to the interceptor object. 39 // call to the interceptor object.
40 Expect.isTrue(generated.contains('JSNumber_methods.get\$toString(a + 42);')); 40 Expect.isTrue(generated.contains('JSNumber_methods.get\$toString(a + 42);'));
41 41
42 // Check that one-shot interceptors preserve variable names, see 42 // Check that one-shot interceptors preserve variable names, see
43 // https://code.google.com/p/dart/issues/detail?id=8106. 43 // https://code.google.com/p/dart/issues/detail?id=8106.
44 generated = compile(TEST_TWO, entry: 'foo'); 44 generated = compile(TEST_TWO, entry: 'foo');
45 Expect.isTrue(generated.contains(new RegExp(r'[$a-z]+\.\$add\$n\(a, 42\)'))); 45 Expect.isTrue(generated.contains(new RegExp(r'[$a-z]+\.toString\$0\(a\)')));
46 Expect.isTrue(generated.contains('myVariableName')); 46 Expect.isTrue(generated.contains('myVariableName'));
47 47
48 // Check that an intercepted getter that does not need to be 48 // Check that an intercepted getter that does not need to be
49 // intercepted, is turned into a regular getter call or field 49 // intercepted, is turned into a regular getter call or field
50 // access. 50 // access.
51 generated = compile(TEST_THREE, entry: 'foo'); 51 generated = compile(TEST_THREE, entry: 'foo');
52 Expect.isFalse(generated.contains(r'a.get$length()')); 52 Expect.isFalse(generated.contains(r'a.get$length()'));
53 Expect.isTrue(generated.contains(new RegExp(r'[$a-z]+\.A\$\(\)\.length'))); 53 Expect.isTrue(generated.contains(new RegExp(r'[$a-z]+\.A\$\(\)\.length')));
54 Expect.isTrue( 54 Expect.isTrue(
55 generated.contains(new RegExp(r'[$a-z]+\.get\$length\$a\(a\)'))); 55 generated.contains(new RegExp(r'[$a-z]+\.get\$length\$a\(a\)')));
56 } 56 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/code_motion_test.dart ('k') | tests/compiler/dart2js/is_inference_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698