-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* don't generate script tag * handle U+2028 and U+2029 * handle name conflict with constructor [email protected] Review URL: https://codereview.chromium.org/1347453002 .
- Loading branch information
John Messerly
committed
Sep 15, 2015
1 parent
637c2c8
commit ff1b78c
Showing
10 changed files
with
166 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
#!/usr/bin/env iojs | ||
dart_library.library('script', null, /* Imports */[ | ||
"dart_runtime/dart", | ||
'dart/core' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
import "package:expect/expect.dart"; | ||
|
||
class A { | ||
var __PROTO__ = 499; | ||
var constructor = 1; | ||
var prototype = 2; | ||
} | ||
|
||
// TODO(jmesserly): changed this test to avoid shadowing a field with a getter, | ||
// which DDC doesn't currently support, see: | ||
// https://github.com/dart-lang/dev_compiler/issues/52 | ||
class A2 { | ||
get __PROTO__ => 499; | ||
get constructor => 1; | ||
get prototype => 2; | ||
} | ||
|
||
class B extends A2 { | ||
get __PROTO__ => 42; | ||
get constructor => 3; | ||
get prototype => 4; | ||
} | ||
|
||
main() { | ||
var a = new A(); | ||
var a2 = new A2(); | ||
var b = new B(); | ||
var list = [a, a2, b]; | ||
for (int i = 0; i < list.length; i++) { | ||
var proto = list[i].__PROTO__; | ||
var constructor = list[i].constructor; | ||
var prototype = list[i].prototype; | ||
if (i < 2) { | ||
Expect.equals(499, proto); | ||
Expect.equals(1, constructor); | ||
Expect.equals(2, prototype); | ||
} else { | ||
Expect.equals(42, proto); | ||
Expect.equals(3, constructor); | ||
Expect.equals(4, prototype); | ||
} | ||
} | ||
} |
81 changes: 81 additions & 0 deletions
81
pkg/dev_compiler/test/codegen/language/optimized_string_charcodeat_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
// VMOptions=--optimization-counter-threshold=10 --no-use-osr | ||
|
||
// Test optimized CodeUnitAt and array access. | ||
|
||
import "package:expect/expect.dart"; | ||
|
||
|
||
String one_byte = "hest"; | ||
String two_byte = "h\u{2029}ns"; | ||
|
||
int testOneByteCodeUnitAt(String x, int j) { | ||
int test() { | ||
return x.codeUnitAt(j); | ||
} | ||
for (int i = 0; i < 20; i++) test(); | ||
return test(); | ||
} | ||
|
||
|
||
int testTwoByteCodeUnitAt(String x, int j) { | ||
int test() { | ||
return x.codeUnitAt(j); | ||
} | ||
for (int i = 0; i < 20; i++) test(); | ||
return test(); | ||
} | ||
|
||
|
||
int testConstantStringCodeUnitAt(int j) { | ||
int test() { | ||
return "høns".codeUnitAt(j); | ||
} | ||
for (int i = 0; i < 20; i++) test(); | ||
return test(); | ||
} | ||
|
||
|
||
int testConstantIndexCodeUnitAt(String x) { | ||
int test() { | ||
return x.codeUnitAt(1); | ||
} | ||
for (int i = 0; i < 20; i++) test(); | ||
return test(); | ||
} | ||
|
||
|
||
int testOneByteCodeUnitAtInLoop(var x) { | ||
var result = 0; | ||
for (int i = 0; i < x.length; i++) { | ||
result += x.codeUnitAt(i); | ||
} | ||
return result; | ||
} | ||
|
||
|
||
int testTwoByteCodeUnitAtInLoop(var x) { | ||
var result = 0; | ||
for (int i = 0; i < x.length; i++) { | ||
result += x.codeUnitAt(i); | ||
} | ||
return result; | ||
} | ||
|
||
|
||
main() { | ||
for (int j = 0; j < 10; j++) { | ||
Expect.equals(101, testOneByteCodeUnitAt(one_byte, 1)); | ||
Expect.equals(8233, testTwoByteCodeUnitAt(two_byte, 1)); | ||
Expect.equals(248, testConstantStringCodeUnitAt(1)); | ||
Expect.equals(101, testConstantIndexCodeUnitAt(one_byte)); | ||
} | ||
for (int j = 0; j < 20; j++) { | ||
Expect.equals(436, testOneByteCodeUnitAtInLoop(one_byte)); | ||
Expect.equals(8562, testTwoByteCodeUnitAtInLoop(two_byte)); | ||
} | ||
Expect.throws(() => testOneByteCodeUnitAtInLoop(123)); | ||
Expect.throws(() => testTwoByteCodeUnitAtInLoop(123)); | ||
} |