mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 10:33:28 +00:00
Migrate standalone_2 to null safety.
Change-Id: I0e97add738bc79314a210cf137525b7391467fc2 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152595 Reviewed-by: Siva Annamalai <asiva@google.com> Commit-Queue: Bob Nystrom <rnystrom@google.com> Auto-Submit: Bob Nystrom <rnystrom@google.com>
This commit is contained in:
parent
25d8ae53c1
commit
35da19ac07
22
tests/standalone/byte_array_view_optimized_test.dart
Normal file
22
tests/standalone/byte_array_view_optimized_test.dart
Normal file
|
@ -0,0 +1,22 @@
|
|||
// Copyright (c) 2013, 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.
|
||||
|
||||
// Test optimization of byte array views on external data.
|
||||
|
||||
// Library tag to be able to run in html test framework.
|
||||
library ByteArrayViewOptimizedTest;
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
import "dart:typed_data";
|
||||
|
||||
li16(v) => v[0];
|
||||
|
||||
main() {
|
||||
var a = new Uint8List(2);
|
||||
a[0] = a[1] = 0xff;
|
||||
var b = new Int16List.view(a.buffer);
|
||||
Expect.equals(-1, li16(b));
|
||||
for (var i = 0; i < 10000; i++) li16(b);
|
||||
Expect.equals(-1, li16(b));
|
||||
}
|
338
tests/standalone/bytedata_test.dart
Normal file
338
tests/standalone/bytedata_test.dart
Normal file
|
@ -0,0 +1,338 @@
|
|||
// Copyright (c) 2013, 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.
|
||||
//
|
||||
// Dart test program for testing typed data.
|
||||
|
||||
// Library tag to be able to run in html test framework.
|
||||
library ByteDataTest;
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
import 'dart:typed_data';
|
||||
|
||||
testGetters() {
|
||||
bool host_is_little_endian =
|
||||
(new Uint8List.view(new Uint16List.fromList([1]).buffer))[0] == 1;
|
||||
|
||||
var list = new Uint8List(8);
|
||||
list[0] = 0xf1;
|
||||
list[1] = 0xf2;
|
||||
list[2] = 0xf3;
|
||||
list[3] = 0xf4;
|
||||
list[4] = 0xf5;
|
||||
list[5] = 0xf6;
|
||||
list[6] = 0xf7;
|
||||
list[7] = 0xf8;
|
||||
var ba = list.buffer;
|
||||
|
||||
ByteData bd = new ByteData.view(ba);
|
||||
var value;
|
||||
int expected_value_be = -3598;
|
||||
int expected_value_le = -3343;
|
||||
|
||||
value = bd.getInt16(0); // Default is big endian access.
|
||||
Expect.equals(expected_value_be, value);
|
||||
value = bd.getInt16(0, Endian.big);
|
||||
Expect.equals(expected_value_be, value);
|
||||
value = bd.getInt16(0, Endian.little);
|
||||
Expect.equals(expected_value_le, value);
|
||||
value = bd.getInt16(0, Endian.host);
|
||||
if (host_is_little_endian) {
|
||||
Expect.isTrue(identical(Endian.host, Endian.little));
|
||||
Expect.equals(expected_value_le, value);
|
||||
} else {
|
||||
Expect.isTrue(identical(Endian.host, Endian.big));
|
||||
Expect.equals(expected_value_be, value);
|
||||
}
|
||||
|
||||
value = bd.getUint16(0); // Default is big endian access.
|
||||
Expect.equals(0xf1f2, value);
|
||||
value = bd.getUint16(0, Endian.big);
|
||||
Expect.equals(0xf1f2, value);
|
||||
value = bd.getUint16(0, Endian.little);
|
||||
Expect.equals(0xf2f1, value);
|
||||
if (host_is_little_endian) {
|
||||
Expect.isTrue(identical(Endian.host, Endian.little));
|
||||
Expect.equals(0xf2f1, value);
|
||||
} else {
|
||||
Expect.isTrue(identical(Endian.host, Endian.big));
|
||||
Expect.equals(0xf1f2, value);
|
||||
}
|
||||
|
||||
expected_value_be = -235736076;
|
||||
expected_value_le = -185339151;
|
||||
|
||||
value = bd.getInt32(0); // Default is big endian access.
|
||||
Expect.equals(expected_value_be, value);
|
||||
value = bd.getInt32(0, Endian.big);
|
||||
Expect.equals(expected_value_be, value);
|
||||
value = bd.getInt32(0, Endian.little);
|
||||
Expect.equals(expected_value_le, value);
|
||||
if (host_is_little_endian) {
|
||||
Expect.isTrue(identical(Endian.host, Endian.little));
|
||||
Expect.equals(expected_value_le, value);
|
||||
} else {
|
||||
Expect.isTrue(identical(Endian.host, Endian.big));
|
||||
Expect.equals(expected_value_be, value);
|
||||
}
|
||||
|
||||
value = bd.getUint32(0); // Default is big endian access.
|
||||
Expect.equals(0xf1f2f3f4, value);
|
||||
value = bd.getUint32(0, Endian.big);
|
||||
Expect.equals(0xf1f2f3f4, value);
|
||||
value = bd.getUint32(0, Endian.little);
|
||||
Expect.equals(0xf4f3f2f1, value);
|
||||
if (host_is_little_endian) {
|
||||
Expect.isTrue(identical(Endian.host, Endian.little));
|
||||
Expect.equals(0xf4f3f2f1, value);
|
||||
} else {
|
||||
Expect.isTrue(identical(Endian.host, Endian.big));
|
||||
Expect.equals(0xf1f2f3f4, value);
|
||||
}
|
||||
|
||||
expected_value_be = -1012478732780767240;
|
||||
expected_value_le = -506664896818842895;
|
||||
|
||||
value = bd.getInt64(0); // Default is big endian access.
|
||||
Expect.equals(expected_value_be, value);
|
||||
value = bd.getInt64(0, Endian.big);
|
||||
Expect.equals(expected_value_be, value);
|
||||
value = bd.getInt64(0, Endian.little);
|
||||
Expect.equals(expected_value_le, value);
|
||||
if (host_is_little_endian) {
|
||||
Expect.isTrue(identical(Endian.host, Endian.little));
|
||||
Expect.equals(expected_value_le, value);
|
||||
} else {
|
||||
Expect.isTrue(identical(Endian.host, Endian.big));
|
||||
Expect.equals(expected_value_be, value);
|
||||
}
|
||||
|
||||
value = bd.getUint64(0); // Default is big endian access.
|
||||
Expect.equals(0xf1f2f3f4f5f6f7f8, value);
|
||||
value = bd.getUint64(0, Endian.big);
|
||||
Expect.equals(0xf1f2f3f4f5f6f7f8, value);
|
||||
value = bd.getUint64(0, Endian.little);
|
||||
Expect.equals(0xf8f7f6f5f4f3f2f1, value);
|
||||
if (host_is_little_endian) {
|
||||
Expect.isTrue(identical(Endian.host, Endian.little));
|
||||
Expect.equals(0xf8f7f6f5f4f3f2f1, value);
|
||||
} else {
|
||||
Expect.isTrue(identical(Endian.host, Endian.big));
|
||||
Expect.equals(0xf1f2f3f4f5f6f7f8, value);
|
||||
}
|
||||
|
||||
double expected_be_value = -2.4060893954673178e+30;
|
||||
double expected_le_value = -1.5462104171572421e+32;
|
||||
value = bd.getFloat32(0); // Default is big endian access.
|
||||
Expect.equals(expected_be_value, value);
|
||||
value = bd.getFloat32(0, Endian.big);
|
||||
Expect.equals(expected_be_value, value);
|
||||
value = bd.getFloat32(0, Endian.little);
|
||||
Expect.equals(expected_le_value, value);
|
||||
if (host_is_little_endian) {
|
||||
Expect.isTrue(identical(Endian.host, Endian.little));
|
||||
Expect.equals(expected_le_value, value);
|
||||
} else {
|
||||
Expect.isTrue(identical(Endian.host, Endian.big));
|
||||
Expect.equals(expected_be_value, value);
|
||||
}
|
||||
|
||||
expected_be_value = -7.898661740976602e+240;
|
||||
expected_le_value = -5.185705956736366e+274;
|
||||
value = bd.getFloat64(0); // Default is big endian access.
|
||||
Expect.equals(expected_be_value, value);
|
||||
value = bd.getFloat64(0, Endian.big);
|
||||
Expect.equals(expected_be_value, value);
|
||||
value = bd.getFloat64(0, Endian.little);
|
||||
Expect.equals(expected_le_value, value);
|
||||
if (host_is_little_endian) {
|
||||
Expect.isTrue(identical(Endian.host, Endian.little));
|
||||
Expect.equals(expected_le_value, value);
|
||||
} else {
|
||||
Expect.isTrue(identical(Endian.host, Endian.big));
|
||||
Expect.equals(expected_be_value, value);
|
||||
}
|
||||
}
|
||||
|
||||
validate16be(var list) {
|
||||
Expect.equals(0xf1, list[0]);
|
||||
Expect.equals(0xf2, list[1]);
|
||||
}
|
||||
|
||||
validate16le(var list) {
|
||||
Expect.equals(0xf2, list[0]);
|
||||
Expect.equals(0xf1, list[1]);
|
||||
}
|
||||
|
||||
validate32be(var list) {
|
||||
Expect.equals(0xf1, list[0]);
|
||||
Expect.equals(0xf2, list[1]);
|
||||
Expect.equals(0xf3, list[2]);
|
||||
Expect.equals(0xf4, list[3]);
|
||||
}
|
||||
|
||||
validate32le(var list) {
|
||||
Expect.equals(0xf4, list[0]);
|
||||
Expect.equals(0xf3, list[1]);
|
||||
Expect.equals(0xf2, list[2]);
|
||||
Expect.equals(0xf1, list[3]);
|
||||
}
|
||||
|
||||
validate64be(var list) {
|
||||
Expect.equals(0xf1, list[0]);
|
||||
Expect.equals(0xf2, list[1]);
|
||||
Expect.equals(0xf3, list[2]);
|
||||
Expect.equals(0xf4, list[3]);
|
||||
Expect.equals(0xf5, list[4]);
|
||||
Expect.equals(0xf6, list[5]);
|
||||
Expect.equals(0xf7, list[6]);
|
||||
Expect.equals(0xf8, list[7]);
|
||||
}
|
||||
|
||||
validate64le(var list) {
|
||||
Expect.equals(0xf8, list[0]);
|
||||
Expect.equals(0xf7, list[1]);
|
||||
Expect.equals(0xf6, list[2]);
|
||||
Expect.equals(0xf5, list[3]);
|
||||
Expect.equals(0xf4, list[4]);
|
||||
Expect.equals(0xf3, list[5]);
|
||||
Expect.equals(0xf2, list[6]);
|
||||
Expect.equals(0xf1, list[7]);
|
||||
}
|
||||
|
||||
testSetters() {
|
||||
bool host_is_little_endian =
|
||||
(new Uint8List.view(new Uint16List.fromList([1]).buffer))[0] == 1;
|
||||
|
||||
var list = new Uint8List(8);
|
||||
for (int i = 0; i < list.length; i++) {
|
||||
list[i] = 0;
|
||||
}
|
||||
var ba = list.buffer;
|
||||
ByteData bd = new ByteData.view(ba);
|
||||
|
||||
bd.setInt16(0, 0xf1f2); // Default is big endian access.
|
||||
validate16be(list);
|
||||
bd.setInt16(0, 0xf1f2, Endian.big);
|
||||
validate16be(list);
|
||||
bd.setInt16(0, 0xf1f2, Endian.little);
|
||||
validate16le(list);
|
||||
bd.setInt16(0, 0xf1f2, Endian.host);
|
||||
if (host_is_little_endian) {
|
||||
Expect.isTrue(identical(Endian.host, Endian.little));
|
||||
validate16le(list);
|
||||
} else {
|
||||
Expect.isTrue(identical(Endian.host, Endian.big));
|
||||
validate16be(list);
|
||||
}
|
||||
|
||||
bd.setUint16(0, 0xf1f2); // Default is big endian access.
|
||||
validate16be(list);
|
||||
bd.setUint16(0, 0xf1f2, Endian.big);
|
||||
validate16be(list);
|
||||
bd.setUint16(0, 0xf1f2, Endian.little);
|
||||
validate16le(list);
|
||||
bd.setUint16(0, 0xf1f2, Endian.host);
|
||||
if (host_is_little_endian) {
|
||||
Expect.isTrue(identical(Endian.host, Endian.little));
|
||||
validate16le(list);
|
||||
} else {
|
||||
Expect.isTrue(identical(Endian.host, Endian.big));
|
||||
validate16be(list);
|
||||
}
|
||||
|
||||
bd.setInt32(0, 0xf1f2f3f4); // Default is big endian access.
|
||||
validate32be(list);
|
||||
bd.setInt32(0, 0xf1f2f3f4, Endian.big);
|
||||
validate32be(list);
|
||||
bd.setInt32(0, 0xf1f2f3f4, Endian.little);
|
||||
validate32le(list);
|
||||
bd.setInt32(0, 0xf1f2f3f4, Endian.host);
|
||||
if (host_is_little_endian) {
|
||||
Expect.isTrue(identical(Endian.host, Endian.little));
|
||||
validate32le(list);
|
||||
} else {
|
||||
Expect.isTrue(identical(Endian.host, Endian.big));
|
||||
validate32be(list);
|
||||
}
|
||||
|
||||
bd.setUint32(0, 0xf1f2f3f4); // Default is big endian access.
|
||||
validate32be(list);
|
||||
bd.setUint32(0, 0xf1f2f3f4, Endian.big);
|
||||
validate32be(list);
|
||||
bd.setUint32(0, 0xf1f2f3f4, Endian.little);
|
||||
validate32le(list);
|
||||
bd.setUint32(0, 0xf1f2f3f4, Endian.host);
|
||||
if (host_is_little_endian) {
|
||||
Expect.isTrue(identical(Endian.host, Endian.little));
|
||||
validate32le(list);
|
||||
} else {
|
||||
Expect.isTrue(identical(Endian.host, Endian.big));
|
||||
validate32be(list);
|
||||
}
|
||||
|
||||
bd.setInt64(0, 0xf1f2f3f4f5f6f7f8); // Default is big endian access.
|
||||
validate64be(list);
|
||||
bd.setInt64(0, 0xf1f2f3f4f5f6f7f8, Endian.big);
|
||||
validate64be(list);
|
||||
bd.setInt64(0, 0xf1f2f3f4f5f6f7f8, Endian.little);
|
||||
validate64le(list);
|
||||
bd.setInt64(0, 0xf1f2f3f4f5f6f7f8, Endian.host);
|
||||
if (host_is_little_endian) {
|
||||
Expect.isTrue(identical(Endian.host, Endian.little));
|
||||
validate64le(list);
|
||||
} else {
|
||||
Expect.isTrue(identical(Endian.host, Endian.big));
|
||||
validate64be(list);
|
||||
}
|
||||
|
||||
bd.setUint64(0, 0xf1f2f3f4f5f6f7f8); // Default is big endian access.
|
||||
validate64be(list);
|
||||
bd.setUint64(0, 0xf1f2f3f4f5f6f7f8, Endian.big);
|
||||
validate64be(list);
|
||||
bd.setUint64(0, 0xf1f2f3f4f5f6f7f8, Endian.little);
|
||||
validate64le(list);
|
||||
bd.setUint64(0, 0xf1f2f3f4f5f6f7f8, Endian.host);
|
||||
if (host_is_little_endian) {
|
||||
Expect.isTrue(identical(Endian.host, Endian.little));
|
||||
validate64le(list);
|
||||
} else {
|
||||
Expect.isTrue(identical(Endian.host, Endian.big));
|
||||
validate64be(list);
|
||||
}
|
||||
|
||||
bd.setFloat32(0, -2.4060893954673178e+30); // Default is big endian access.
|
||||
validate32be(list);
|
||||
bd.setFloat32(0, -2.4060893954673178e+30, Endian.big);
|
||||
validate32be(list);
|
||||
bd.setFloat32(0, -2.4060893954673178e+30, Endian.little);
|
||||
validate32le(list);
|
||||
bd.setFloat32(0, -2.4060893954673178e+30, Endian.host);
|
||||
if (host_is_little_endian) {
|
||||
Expect.isTrue(identical(Endian.host, Endian.little));
|
||||
validate32le(list);
|
||||
} else {
|
||||
Expect.isTrue(identical(Endian.host, Endian.big));
|
||||
validate32be(list);
|
||||
}
|
||||
|
||||
bd.setFloat64(0, -7.898661740976602e+240); // Default is big endian access.
|
||||
validate64be(list);
|
||||
bd.setFloat64(0, -7.898661740976602e+240, Endian.big);
|
||||
validate64be(list);
|
||||
bd.setFloat64(0, -7.898661740976602e+240, Endian.little);
|
||||
validate64le(list);
|
||||
bd.setFloat64(0, -7.898661740976602e+240, Endian.host);
|
||||
if (host_is_little_endian) {
|
||||
Expect.isTrue(identical(Endian.host, Endian.little));
|
||||
validate64le(list);
|
||||
} else {
|
||||
Expect.isTrue(identical(Endian.host, Endian.big));
|
||||
validate64be(list);
|
||||
}
|
||||
}
|
||||
|
||||
main() {
|
||||
testGetters();
|
||||
testSetters();
|
||||
}
|
35
tests/standalone/causal_async_stack_test.dart
Normal file
35
tests/standalone/causal_async_stack_test.dart
Normal file
|
@ -0,0 +1,35 @@
|
|||
// Copyright (c) 2017, 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=--causal_async_stacks --no-lazy-async-stacks
|
||||
// VMOptions=--no-causal_async_stacks --lazy-async-stacks
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
noop() async => Future.value(null);
|
||||
|
||||
baz() async {
|
||||
// Throw exception after the first continuation, when there is no
|
||||
// original stack trace.
|
||||
await noop();
|
||||
throw "Bad!";
|
||||
}
|
||||
|
||||
bar() async {
|
||||
await baz();
|
||||
}
|
||||
|
||||
foo() async {
|
||||
await bar();
|
||||
}
|
||||
|
||||
main() async {
|
||||
try {
|
||||
await foo();
|
||||
} catch (e, st) {
|
||||
Expect.isTrue(st.toString().contains("baz"));
|
||||
Expect.isTrue(st.toString().contains("bar"));
|
||||
Expect.isTrue(st.toString().contains("foo"));
|
||||
Expect.isTrue(st.toString().contains("main"));
|
||||
}
|
||||
}
|
66
tests/standalone/check_class_cha_test.dart
Normal file
66
tests/standalone/check_class_cha_test.dart
Normal file
|
@ -0,0 +1,66 @@
|
|||
// Copyright (c) 2018, 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 hierarchy on an abstract class
|
||||
// that defines a "next" structure.
|
||||
|
||||
abstract class A {
|
||||
A? next;
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
B(A? n) {
|
||||
this.next = n;
|
||||
}
|
||||
}
|
||||
|
||||
// Method that counts length of list.
|
||||
// With only Bs, the getter can be
|
||||
// inlined without check class.
|
||||
int countMe(A? i) {
|
||||
int x = 0;
|
||||
while (i != null) {
|
||||
A? next = i.next;
|
||||
x++;
|
||||
i = next;
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
int doitHot(A? a) {
|
||||
// Warm up the JIT.
|
||||
int d = 0;
|
||||
for (int i = 0; i < 1000; i++) {
|
||||
d += countMe(a);
|
||||
}
|
||||
return d;
|
||||
}
|
||||
|
||||
// Nasty class that overrides the getter.
|
||||
class C extends A {
|
||||
C(A? n) {
|
||||
this.next = n;
|
||||
}
|
||||
// New override.
|
||||
A? get next => null;
|
||||
}
|
||||
|
||||
int bringInC(A? a) {
|
||||
// Introduce C to compiler.
|
||||
a = new C(a);
|
||||
return doitHot(a);
|
||||
}
|
||||
|
||||
main() {
|
||||
// Make a list with just Bs.
|
||||
A? a = null;
|
||||
for (int i = 0; i < 1000; i++) {
|
||||
a = new B(a);
|
||||
}
|
||||
|
||||
Expect.equals(1000 * 1000, doitHot(a));
|
||||
Expect.equals(1000, bringInC(a));
|
||||
}
|
58
tests/standalone/check_null_cha_test.dart
Normal file
58
tests/standalone/check_null_cha_test.dart
Normal file
|
@ -0,0 +1,58 @@
|
|||
// Copyright (c) 2018, 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";
|
||||
|
||||
// A class the has a getter also provided by Object
|
||||
// (higher in the class hierarchy) and thus also the
|
||||
// Null class (besides X in the class hierarchy).
|
||||
class X {
|
||||
int hashCode = -1;
|
||||
X() {
|
||||
hashCode = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Use this getter on X receiver.
|
||||
int hashMe(X? x) {
|
||||
int d = 0;
|
||||
for (int i = 0; i < 10; i++) {
|
||||
d += x.hashCode;
|
||||
}
|
||||
return d;
|
||||
}
|
||||
|
||||
// Use this getter on Null class receiver.
|
||||
// Only possible value is null.
|
||||
int hashNull(Null x) {
|
||||
int d = 0;
|
||||
for (int i = 0; i < 10; i++) {
|
||||
d += x.hashCode;
|
||||
}
|
||||
return d;
|
||||
}
|
||||
|
||||
main() {
|
||||
// Warm up the JIT with just an X object. Having a single receiver
|
||||
// of type X with nothing below in the hierarchy that overrides
|
||||
// hashCode could tempt the JIT to inline the getter with CHA
|
||||
// that deopts when X is subclassed in the future.
|
||||
X x = new X();
|
||||
for (int i = 0; i < 1000; i++) {
|
||||
Expect.equals(10, hashMe(x));
|
||||
}
|
||||
|
||||
// However, this is a special case that also works on null
|
||||
// (calling Object's hashCode). So this should not throw an
|
||||
// exception. Had we inlined, this would have hit the null
|
||||
// check and thrown an exception.
|
||||
Expect.notEquals(0, hashMe(null));
|
||||
|
||||
// Also warm up the JIT on a direct Null receiver.
|
||||
int d = 0;
|
||||
for (int i = 0; i < 1000; i++) {
|
||||
d += hashNull(null);
|
||||
}
|
||||
Expect.notEquals(0, d);
|
||||
}
|
78
tests/standalone/constant_left_shift_test.dart
Normal file
78
tests/standalone/constant_left_shift_test.dart
Normal file
|
@ -0,0 +1,78 @@
|
|||
// 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.
|
||||
//
|
||||
// Dart test program for testing left shifts of a constant.
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
shiftLeft0(c) => 0 << c;
|
||||
shiftLeft1(c) => 1 << c;
|
||||
shiftLeft8448(c) => 8448 << c;
|
||||
|
||||
shiftLeftNeg1(c) => -1 << c;
|
||||
shiftLeftNeg8448(c) => -8448 << c;
|
||||
|
||||
main() {
|
||||
// Optimize shifts.
|
||||
for (int i = 0; i < 6000; i++) {
|
||||
shiftLeft1(2);
|
||||
shiftLeft0(2);
|
||||
shiftLeft8448(2);
|
||||
shiftLeftNeg1(2);
|
||||
shiftLeftNeg8448(2);
|
||||
}
|
||||
for (int i = 0; i < 80; i++) {
|
||||
Expect.equals(0, shiftLeft0(i));
|
||||
}
|
||||
// Exceptions.
|
||||
Expect.throws(() => shiftLeft0(-1));
|
||||
|
||||
Expect.equals(1, shiftLeft1(0));
|
||||
Expect.equals(128, shiftLeft1(7));
|
||||
Expect.equals(536870912, shiftLeft1(29));
|
||||
// Deoptimize on 32-bit.
|
||||
Expect.equals(1073741824, shiftLeft1(30));
|
||||
Expect.equals(2147483648, shiftLeft1(31));
|
||||
Expect.equals(1152921504606846976, shiftLeft1(60));
|
||||
Expect.equals(2305843009213693952, shiftLeft1(61));
|
||||
// Deoptimize on 64 bits.
|
||||
Expect.equals(4611686018427387904, shiftLeft1(62));
|
||||
Expect.equals(-9223372036854775808, shiftLeft1(63));
|
||||
|
||||
Expect.equals(8448, shiftLeft8448(0));
|
||||
Expect.equals(1081344, shiftLeft8448(7));
|
||||
Expect.equals(553648128, shiftLeft8448(16));
|
||||
// Deoptimize on 32-bit.
|
||||
Expect.equals(1107296256, shiftLeft8448(17));
|
||||
Expect.equals(2214592512, shiftLeft8448(18));
|
||||
Expect.equals(1188950301625810944, shiftLeft8448(47));
|
||||
Expect.equals(2377900603251621888, shiftLeft8448(48));
|
||||
// Deoptimize on 64 bits.
|
||||
Expect.equals(4755801206503243776, shiftLeft8448(49));
|
||||
Expect.equals(-8935141660703064064, shiftLeft8448(50));
|
||||
|
||||
Expect.equals(-1, shiftLeftNeg1(0));
|
||||
Expect.equals(-128, shiftLeftNeg1(7));
|
||||
Expect.equals(-536870912, shiftLeftNeg1(29));
|
||||
// Deoptimize on 32-bit.
|
||||
Expect.equals(-1073741824, shiftLeftNeg1(30));
|
||||
Expect.equals(-2147483648, shiftLeftNeg1(31));
|
||||
Expect.equals(-1152921504606846976, shiftLeftNeg1(60));
|
||||
Expect.equals(-2305843009213693952, shiftLeftNeg1(61));
|
||||
// Deoptimize on 64 bits.
|
||||
Expect.equals(-4611686018427387904, shiftLeftNeg1(62));
|
||||
Expect.equals(-9223372036854775808, shiftLeftNeg1(63));
|
||||
|
||||
Expect.equals(-8448, shiftLeftNeg8448(0));
|
||||
Expect.equals(-1081344, shiftLeftNeg8448(7));
|
||||
Expect.equals(-553648128, shiftLeftNeg8448(16));
|
||||
// Deoptimize on 32-bit.
|
||||
Expect.equals(-1107296256, shiftLeftNeg8448(17));
|
||||
Expect.equals(-2214592512, shiftLeftNeg8448(18));
|
||||
Expect.equals(-1188950301625810944, shiftLeftNeg8448(47));
|
||||
Expect.equals(-2377900603251621888, shiftLeftNeg8448(48));
|
||||
// Deoptimize on 64 bits.
|
||||
Expect.equals(-4755801206503243776, shiftLeftNeg8448(49));
|
||||
Expect.equals(8935141660703064064, shiftLeftNeg8448(50));
|
||||
}
|
11
tests/standalone/dart_developer_disabled_env_test.dart
Normal file
11
tests/standalone/dart_developer_disabled_env_test.dart
Normal file
|
@ -0,0 +1,11 @@
|
|||
// Copyright (c) 2017, 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=--no_causal_async_stacks
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
main() {
|
||||
Expect.isFalse(
|
||||
const bool.fromEnvironment('dart.developer.causal_async_stacks'));
|
||||
}
|
11
tests/standalone/dart_developer_env2_test.dart
Normal file
11
tests/standalone/dart_developer_env2_test.dart
Normal file
|
@ -0,0 +1,11 @@
|
|||
// Copyright (c) 2020, 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=--lazy-async-stacks --no-causal-async-stacks
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
main() {
|
||||
Expect.isFalse(
|
||||
const bool.fromEnvironment('dart.developer.causal_async_stacks'));
|
||||
}
|
11
tests/standalone/dart_developer_env_test.dart
Normal file
11
tests/standalone/dart_developer_env_test.dart
Normal file
|
@ -0,0 +1,11 @@
|
|||
// Copyright (c) 2017, 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=--no-lazy-async-stacks --causal-async-stacks
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
main() {
|
||||
Expect
|
||||
.isTrue(const bool.fromEnvironment('dart.developer.causal_async_stacks'));
|
||||
}
|
2
tests/standalone/deferred/alpha.dart
Normal file
2
tests/standalone/deferred/alpha.dart
Normal file
|
@ -0,0 +1,2 @@
|
|||
// beta.dart does not exist!
|
||||
import 'beta.dart';
|
1
tests/standalone/deferred/exists.dart
Normal file
1
tests/standalone/deferred/exists.dart
Normal file
|
@ -0,0 +1 @@
|
|||
var x = 99;
|
1
tests/standalone/deferred/transitive_error.dart
Normal file
1
tests/standalone/deferred/transitive_error.dart
Normal file
|
@ -0,0 +1 @@
|
|||
import 'alpha.dart';
|
29
tests/standalone/deferred_transitive_import_error_test.dart
Normal file
29
tests/standalone/deferred_transitive_import_error_test.dart
Normal file
|
@ -0,0 +1,29 @@
|
|||
// Copyright (c) 2016, 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";
|
||||
// A deferred library that doesn't exist.
|
||||
import 'package:foo/foo.dart' deferred as foo;
|
||||
// A deferred library that does exist.
|
||||
import 'deferred/exists.dart' deferred as exists;
|
||||
// A deferred library that transitively will fail due to a file not found.
|
||||
import 'deferred/transitive_error.dart' deferred as te;
|
||||
|
||||
main() async {
|
||||
// Attempt to load foo which will fail.
|
||||
var fooError;
|
||||
await foo.loadLibrary().catchError((e) {
|
||||
fooError = e;
|
||||
});
|
||||
Expect.isNotNull(fooError);
|
||||
await exists.loadLibrary();
|
||||
Expect.equals(99, exists.x);
|
||||
/* TODO(johnmccutchan): Implement transitive error reporting.
|
||||
var teError;
|
||||
await te.loadLibrary().catchError((e) {
|
||||
teError = e;
|
||||
});
|
||||
Expect.isNotNull(teError);
|
||||
*/
|
||||
}
|
59
tests/standalone/deny_listed_test.dart
Normal file
59
tests/standalone/deny_listed_test.dart
Normal file
|
@ -0,0 +1,59 @@
|
|||
// Copyright (c) 2011, 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.
|
||||
// Dart test checking that static/instance field shadowing do not conflict.
|
||||
|
||||
// Test that certain interfaces/classes are denylisted from being
|
||||
// implemented or extended (VM corelib only).
|
||||
|
||||
library BlackListedTest;
|
||||
|
||||
class MyBool extends Bool {} // //# 01: compile-time error
|
||||
|
||||
class MyDouble extends Double {} // //# 02: compile-time error
|
||||
|
||||
class MyObjectArray extends ObjectArray {} // //# 03: compile-time error
|
||||
|
||||
class MyImmutableArray extends ImmutableArray {} // //# 04: compile-time error
|
||||
|
||||
class MyGrowableObjectArray extends GrowableObjectArray {} // //# 05: compile-time error
|
||||
|
||||
class MyIntegerImplementation extends IntegerImplementation {} // //# 06: compile-time error
|
||||
|
||||
class MySmi extends Smi {} // //# 07: compile-time error
|
||||
|
||||
class MyMint extends Mint {} // //# 08: compile-time error
|
||||
|
||||
class MyBigint extends Bigint {} // //# 09: compile-time error
|
||||
|
||||
class MyOneByteString extends OneByteString {} // //# 10: compile-time error
|
||||
|
||||
class MyTwoByteString extends TwoByteString {} // //# 11: compile-time error
|
||||
|
||||
class MyFourByteString extends FourByteString {} // //# 12: compile-time error
|
||||
|
||||
main() {
|
||||
new MyBool(); //# 01: continued
|
||||
|
||||
new MyDouble(); //# 02: continued
|
||||
|
||||
new MyObjectArray(); //# 03: continued
|
||||
|
||||
new MyImmutableArray(); //# 04: continued
|
||||
|
||||
new MyGrowableObjectArray(); //# 05: continued
|
||||
|
||||
new MyIntegerImplementation(); //# 06: continued
|
||||
|
||||
new MySmi(); //# 07: continued
|
||||
|
||||
new MyMint(); //# 08: continued
|
||||
|
||||
new MyBigint(); //# 09: continued
|
||||
|
||||
new MyOneByteString(); //# 10: continued
|
||||
|
||||
new MyTwoByteString(); //# 11: continued
|
||||
|
||||
new MyFourByteString(); //# 12: continued
|
||||
}
|
215
tests/standalone/deoptimization_test.dart
Normal file
215
tests/standalone/deoptimization_test.dart
Normal file
|
@ -0,0 +1,215 @@
|
|||
// Copyright (c) 2011, 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.
|
||||
// Test deoptimization.
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
class SmiCompares {
|
||||
// Test deoptimization when one argument is known to be Smi.
|
||||
static bool smiCompareLessThan2(a) {
|
||||
return a < 2;
|
||||
}
|
||||
|
||||
// Test deoptimization when one argument is known to be Smi.
|
||||
static bool smiCompareGreaterThan2(a) {
|
||||
return 2 < a;
|
||||
}
|
||||
|
||||
// Test deoptimization when both arguments unknown.
|
||||
static bool smiCompareLessThan(a, b) {
|
||||
return a < b;
|
||||
}
|
||||
|
||||
// Test deoptimization when both arguments unknown.
|
||||
static bool smiCompareGreaterThan(a, b) {
|
||||
return a > b;
|
||||
}
|
||||
|
||||
static smiComparesTest() {
|
||||
for (int i = 0; i < 2000; i++) {
|
||||
Expect.equals(true, smiCompareLessThan2(1));
|
||||
Expect.equals(false, smiCompareLessThan2(3));
|
||||
Expect.equals(false, smiCompareGreaterThan2(1));
|
||||
Expect.equals(true, smiCompareGreaterThan2(3));
|
||||
Expect.equals(true, smiCompareLessThan(1, 2));
|
||||
Expect.equals(false, smiCompareGreaterThan(1, 2));
|
||||
}
|
||||
// Deoptimize by passing a double instead of Smi
|
||||
Expect.equals(true, smiCompareLessThan2(1.0));
|
||||
Expect.equals(false, smiCompareGreaterThan2(1.0));
|
||||
Expect.equals(true, smiCompareLessThan(1.0, 2));
|
||||
Expect.equals(false, smiCompareGreaterThan(1, 2.0));
|
||||
}
|
||||
}
|
||||
|
||||
class SmiBinop {
|
||||
static subWithLiteral(a) {
|
||||
return a - 1;
|
||||
}
|
||||
|
||||
static void smiBinopTest() {
|
||||
for (int i = 0; i < 2000; i++) {
|
||||
Expect.equals(2, subWithLiteral(3));
|
||||
}
|
||||
// Deoptimize.
|
||||
Expect.equals(2.0, subWithLiteral(3.0));
|
||||
}
|
||||
|
||||
static mul(x) {
|
||||
return x * 1024;
|
||||
}
|
||||
|
||||
static void smiBinopOverflowTest() {
|
||||
final int big = 536870912;
|
||||
for (int i = 0; i < 2000; i++) {
|
||||
Expect.equals(1024, mul(1));
|
||||
}
|
||||
// Deoptimize by overflow.
|
||||
Expect.equals(1024 * big, mul(big));
|
||||
}
|
||||
}
|
||||
|
||||
class ObjectsEquality {
|
||||
static bool compareEqual(a, b) {
|
||||
return a == b;
|
||||
}
|
||||
|
||||
static bool compareNotEqual(a, b) {
|
||||
return a != b;
|
||||
}
|
||||
|
||||
// Use only Object.==.
|
||||
static void objectsEqualityTest() {
|
||||
var a = new ObjectsEquality();
|
||||
var b = new ObjectsEquality();
|
||||
for (int i = 0; i < 1000; i++) {
|
||||
Expect.equals(true, compareEqual(a, a));
|
||||
Expect.equals(true, compareEqual(null, null));
|
||||
Expect.equals(false, compareEqual(null, a));
|
||||
Expect.equals(false, compareEqual(a, null));
|
||||
Expect.equals(true, compareEqual(b, b));
|
||||
Expect.equals(false, compareEqual(a, b));
|
||||
|
||||
Expect.equals(false, compareNotEqual(a, a));
|
||||
Expect.equals(false, compareNotEqual(null, null));
|
||||
Expect.equals(true, compareNotEqual(null, a));
|
||||
Expect.equals(true, compareNotEqual(a, null));
|
||||
Expect.equals(false, compareNotEqual(b, b));
|
||||
Expect.equals(true, compareNotEqual(a, b));
|
||||
}
|
||||
var c = new SmiBinop();
|
||||
// Deoptimize.
|
||||
Expect.equals(true, compareEqual(c, c));
|
||||
Expect.equals(false, compareEqual(c, null));
|
||||
Expect.equals(false, compareNotEqual(c, c));
|
||||
Expect.equals(true, compareNotEqual(c, null));
|
||||
}
|
||||
}
|
||||
|
||||
class DeoptimizationTest {
|
||||
static foo(a, b) {
|
||||
return a - b;
|
||||
}
|
||||
|
||||
static test1() {
|
||||
for (int i = 0; i < 2000; i++) {
|
||||
Expect.equals(2, foo(3, 1)); // <-- Optimizes 'foo',
|
||||
}
|
||||
Expect.equals(2.2, foo(1.2, -1.0)); // <-- Deoptimizes 'foo'.
|
||||
for (int i = 0; i < 10000; i++) {
|
||||
Expect.equals(2, foo(3, 1)); // <-- Optimizes 'foo'.
|
||||
}
|
||||
Expect.equals(2.2, foo(1.2, -1)); // <-- Deoptimizes 'foo'.
|
||||
}
|
||||
|
||||
static moo(n) {
|
||||
return ++n;
|
||||
}
|
||||
|
||||
static test2() {
|
||||
for (int i = 0; i < 2000; i++) {
|
||||
Expect.equals(4, moo(3)); // <-- Optimizes 'moo',
|
||||
}
|
||||
Expect.equals(2.2, moo(1.2)); // <-- Deoptimizes 'moo'.
|
||||
for (int i = 0; i < 10000; i++) {
|
||||
Expect.equals(4, moo(3)); // <-- Optimizes 'moo'.
|
||||
}
|
||||
Expect.equals(2.2, moo(1.2)); // <-- Deoptimizes 'moo'.
|
||||
}
|
||||
|
||||
static test3() {
|
||||
for (int i = 0; i < 2000; i++) {
|
||||
Expect.equals(2.0, foo(3.0, 1.0)); // <-- Optimizes 'foo',
|
||||
}
|
||||
Expect.equals(2, foo(1, -1)); // <-- Deoptimizes 'foo'.
|
||||
for (int i = 0; i < 2000; i++) {
|
||||
Expect.equals(2.0, foo(3.0, 1.0)); // <-- Optimizes 'foo',
|
||||
}
|
||||
Expect.equals(2.2, moo(1.2)); // <-- Deoptimizes 'moo'.
|
||||
}
|
||||
|
||||
static bool compareInt(a, b) {
|
||||
return a < b;
|
||||
}
|
||||
|
||||
static bool compareDouble(a, b) {
|
||||
return a < b;
|
||||
}
|
||||
|
||||
static test4() {
|
||||
for (int i = 0; i < 2000; i++) {
|
||||
Expect.equals(true, compareInt(1, 2));
|
||||
Expect.equals(true, compareDouble(1.0, 2.0));
|
||||
}
|
||||
// Trigger deoptimization in compareInt and compareDouble.
|
||||
Expect.equals(true, compareInt(1, 2.0));
|
||||
Expect.equals(true, compareDouble(1.0, 2));
|
||||
}
|
||||
|
||||
static smiRightShift() {
|
||||
int ShiftRight(int a, int b) {
|
||||
return a >> b;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 2000; i++) {
|
||||
var r = ShiftRight(10, 2);
|
||||
Expect.equals(2, r);
|
||||
}
|
||||
// ShiftRight is optimized.
|
||||
Expect.equals(0, ShiftRight(10, 64));
|
||||
// Deoptimize ShiftRight because 'a' is a Mint.
|
||||
var mint = 1 << 63;
|
||||
Expect.equals(-1 << 3, ShiftRight(mint, 60));
|
||||
}
|
||||
|
||||
static doubleUnary() {
|
||||
num unary(num a) {
|
||||
return -a;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 2000; i++) {
|
||||
var r = unary(2.0);
|
||||
Expect.equals(-2.0, r);
|
||||
}
|
||||
var r = unary(5);
|
||||
Expect.equals(-5, r);
|
||||
}
|
||||
|
||||
static void testMain() {
|
||||
test1();
|
||||
test2();
|
||||
test3();
|
||||
test4();
|
||||
SmiCompares.smiComparesTest();
|
||||
SmiBinop.smiBinopTest();
|
||||
SmiBinop.smiBinopOverflowTest();
|
||||
ObjectsEquality.objectsEqualityTest();
|
||||
smiRightShift();
|
||||
doubleUnary();
|
||||
}
|
||||
}
|
||||
|
||||
main() {
|
||||
DeoptimizationTest.testMain();
|
||||
}
|
48
tests/standalone/double_hash_distribution_test.dart
Normal file
48
tests/standalone/double_hash_distribution_test.dart
Normal file
|
@ -0,0 +1,48 @@
|
|||
// Copyright (c) 2017, 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.
|
||||
|
||||
// Test that the distribution of hash codes for doubles is reasonable.
|
||||
|
||||
// VMOptions=--intrinsify
|
||||
// VMOptions=--no_intrinsify
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
|
||||
main() {
|
||||
Expect.isTrue(ratio(0, 1) >= 0.95);
|
||||
Expect.isTrue(ratio(0, 100) >= 0.95);
|
||||
Expect.isTrue(ratio(0, 0xffffff) >= 0.95);
|
||||
Expect.isTrue(ratio(0xffffff) >= 0.95);
|
||||
Expect.isTrue(ratio(0xffffffff) >= 0.95);
|
||||
Expect.isTrue(ratio(0xffffffffffffff) >= 0.95);
|
||||
|
||||
Expect.isTrue(ratio(0, -1) >= 0.95);
|
||||
Expect.isTrue(ratio(0, -100) >= 0.95);
|
||||
Expect.isTrue(ratio(0, -0xffffff) >= 0.95);
|
||||
Expect.isTrue(ratio(-0xffffff) >= 0.95);
|
||||
Expect.isTrue(ratio(-0xffffffff) >= 0.95);
|
||||
Expect.isTrue(ratio(-0xffffffffffffff) >= 0.95);
|
||||
}
|
||||
|
||||
double ratio(num start, [num? end]) {
|
||||
final n = 1000;
|
||||
end ??= (start + 1) * 2;
|
||||
|
||||
// Collect the set of distinct doubles and the
|
||||
// set of distinct hash codes.
|
||||
final doubles = new Set<double>();
|
||||
final codes = new Set<int>();
|
||||
|
||||
final step = (end.toDouble() - start.toDouble()) / n;
|
||||
var current = start.toDouble();
|
||||
for (int i = 0; i < n; i++) {
|
||||
doubles.add(current);
|
||||
codes.add(current.hashCode);
|
||||
current += step;
|
||||
}
|
||||
|
||||
// Return the ratio between distinct doubles and
|
||||
// distinct hash codes.
|
||||
return codes.length / doubles.length;
|
||||
}
|
23
tests/standalone/double_smi_comparison_test.dart
Normal file
23
tests/standalone/double_smi_comparison_test.dart
Normal file
|
@ -0,0 +1,23 @@
|
|||
// Copyright (c) 2011, 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.
|
||||
// Test correct comparison (equality and relational) when mixing double and
|
||||
// Smi arguments. We convert Smi to doubles and to the operation. This is
|
||||
// not correct in 64-bit mode where not every Smi can be converted to a
|
||||
// double without loss of precision.
|
||||
// VMOptions=--optimization-counter-threshold=10 --no-use-osr --no-background-compilation
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
equalityFunc(a, b) => a == b;
|
||||
|
||||
lessThanFunc(a, b) => a < b;
|
||||
|
||||
main() {
|
||||
for (int i = 0; i < 20; i++) {
|
||||
Expect.isFalse(equalityFunc(1.0, 4));
|
||||
Expect.isTrue(lessThanFunc(1.0, 4));
|
||||
}
|
||||
Expect.isFalse(equalityFunc(3459045988797251776, 3459045988797251777));
|
||||
Expect.isTrue(lessThanFunc(3459045988797251776, 3459045988797251777));
|
||||
}
|
38
tests/standalone/double_temp_test.dart
Normal file
38
tests/standalone/double_temp_test.dart
Normal file
|
@ -0,0 +1,38 @@
|
|||
// 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.
|
||||
// Test correct usage of inlined double temporary objects.
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
main() {
|
||||
for (int i = 0; i < 2000; i++) {
|
||||
testBinaryOp();
|
||||
testUnaryOp();
|
||||
}
|
||||
}
|
||||
|
||||
// VM: temporary double should not be used as result of division,
|
||||
// otherwise the function always returns the same object.
|
||||
double divide(double a, double b) {
|
||||
return a / b;
|
||||
}
|
||||
|
||||
testBinaryOp() {
|
||||
var x = divide(1.0, 2.0);
|
||||
var y = divide(2.0, 3.0);
|
||||
Expect.notEquals(x, y);
|
||||
}
|
||||
|
||||
// VM: temporary double should be used only for "-b", otherwise the
|
||||
// function would always return the same object.
|
||||
double unary(double a, double b) {
|
||||
return -(a * (-b));
|
||||
}
|
||||
|
||||
testUnaryOp() {
|
||||
var x = unary(1.0, 2.0);
|
||||
var y = unary(3.0, 4.0);
|
||||
Expect.equals(2.0, x);
|
||||
Expect.equals(12.0, y);
|
||||
}
|
33
tests/standalone/double_to_int_test.dart
Normal file
33
tests/standalone/double_to_int_test.dart
Normal file
|
@ -0,0 +1,33 @@
|
|||
// 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.
|
||||
//
|
||||
// Tests optimization: transform double.toInt() to DoubleToSmi
|
||||
// unless we encounter a non-Smi result, in which case we deoptimize and
|
||||
// optimize it later to DoubleToInt.
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
main() {
|
||||
for (int i = 0; i < 600; i++) {
|
||||
Expect.equals(100, foo(100, 1.2));
|
||||
}
|
||||
// Deoptimize 'foo', d2smi -> d2int.
|
||||
Expect.equals(36507222016 * 2, foo(2, 36507222016.6));
|
||||
for (int i = 0; i < 600; i++) {
|
||||
Expect.equals(100, foo(100, 1.2));
|
||||
}
|
||||
Expect.equals(36507222016 * 2, foo(2, 36507222016.6));
|
||||
}
|
||||
|
||||
foo(n, a) {
|
||||
int k = 0;
|
||||
for (int i = 0; i < n; i++) {
|
||||
k += goo(a);
|
||||
}
|
||||
return k;
|
||||
}
|
||||
|
||||
int goo(a) {
|
||||
return a.toInt();
|
||||
}
|
107
tests/standalone/entrypoints_verification_test.dart
Normal file
107
tests/standalone/entrypoints_verification_test.dart
Normal file
|
@ -0,0 +1,107 @@
|
|||
// Copyright (c) 2019, 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=--verify-entry-points=true
|
||||
|
||||
import 'dart:io';
|
||||
import 'dart:convert';
|
||||
import 'dart:math';
|
||||
import 'package:path/path.dart';
|
||||
import 'package:expect/expect.dart';
|
||||
import 'dart-ext:entrypoints_verification_test_extension';
|
||||
|
||||
void RunTest() native "RunTest";
|
||||
|
||||
main() {
|
||||
RunTest();
|
||||
|
||||
new C();
|
||||
new D();
|
||||
}
|
||||
|
||||
class C {}
|
||||
|
||||
@pragma("vm:entry-point")
|
||||
class D {
|
||||
D();
|
||||
|
||||
@pragma("vm:entry-point")
|
||||
D.defined();
|
||||
|
||||
@pragma("vm:entry-point")
|
||||
factory D.fact() => E.ctor();
|
||||
|
||||
void fn0() {}
|
||||
|
||||
@pragma("vm:entry-point")
|
||||
void fn1() {}
|
||||
|
||||
@pragma("vm:entry-point", "get")
|
||||
void fn1_get() {}
|
||||
|
||||
@pragma("vm:entry-point", "call")
|
||||
void fn1_call() {}
|
||||
|
||||
static void fn2() {}
|
||||
|
||||
@pragma("vm:entry-point")
|
||||
static void fn3() {}
|
||||
|
||||
@pragma("vm:entry-point", "call")
|
||||
static void fn3_call() {}
|
||||
|
||||
@pragma("vm:entry-point", "get")
|
||||
static void fn3_get() {}
|
||||
|
||||
void Function()? fld0;
|
||||
|
||||
@pragma("vm:entry-point")
|
||||
void Function()? fld1;
|
||||
|
||||
@pragma("vm:entry-point", "get")
|
||||
void Function()? fld2;
|
||||
|
||||
@pragma("vm:entry-point", "set")
|
||||
void Function()? fld3;
|
||||
}
|
||||
|
||||
void fn0() {}
|
||||
|
||||
@pragma("vm:entry-point")
|
||||
void fn1() {}
|
||||
|
||||
@pragma("vm:entry-point", "get")
|
||||
void fn1_get() {}
|
||||
|
||||
@pragma("vm:entry-point", "call")
|
||||
void fn1_call() {}
|
||||
|
||||
class E extends D {
|
||||
E.ctor();
|
||||
}
|
||||
|
||||
@pragma("vm:entry-point")
|
||||
class F {
|
||||
static void Function()? fld0;
|
||||
|
||||
@pragma("vm:entry-point")
|
||||
static void Function()? fld1;
|
||||
|
||||
@pragma("vm:entry-point", "get")
|
||||
static void Function()? fld2;
|
||||
|
||||
@pragma("vm:entry-point", "set")
|
||||
static void Function()? fld3;
|
||||
}
|
||||
|
||||
void Function()? fld0;
|
||||
|
||||
@pragma("vm:entry-point")
|
||||
void Function()? fld1;
|
||||
|
||||
@pragma("vm:entry-point", "get")
|
||||
void Function()? fld2;
|
||||
|
||||
@pragma("vm:entry-point", "set")
|
||||
void Function()? fld3;
|
10
tests/standalone/env_test.dart
Normal file
10
tests/standalone/env_test.dart
Normal file
|
@ -0,0 +1,10 @@
|
|||
// Copyright (c) 2016, 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.
|
||||
// SharedOptions=-Dvar -D -D=var -Dvar=invalid -Dvar=valid -Dvar
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
main() {
|
||||
Expect.equals('valid', const String.fromEnvironment('var'));
|
||||
}
|
9
tests/standalone/fields_may_be_reset_test.dart
Normal file
9
tests/standalone/fields_may_be_reset_test.dart
Normal file
|
@ -0,0 +1,9 @@
|
|||
// Copyright (c) 2016, 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=--fields_may_be_reset
|
||||
|
||||
main() {
|
||||
print("Okay");
|
||||
}
|
56
tests/standalone/float_array_static_test.dart
Normal file
56
tests/standalone/float_array_static_test.dart
Normal file
|
@ -0,0 +1,56 @@
|
|||
// 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.
|
||||
//
|
||||
// Dart test program for testing native float arrays.
|
||||
|
||||
// VMOptions=--optimization_counter_threshold=10 --no-background_compilation
|
||||
|
||||
// Library tag to be able to run in html test framework.
|
||||
library FloatArrayTest;
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
import 'dart:typed_data';
|
||||
|
||||
void testIndexOf32() {
|
||||
var list = new Float32List(10);
|
||||
for (int i = 0; i < list.length; i++) {
|
||||
list[i] = i + 10.0;
|
||||
}
|
||||
/*@compile-error=unspecified*/ Expect.equals(0, list.indexOf(10));
|
||||
/*@compile-error=unspecified*/ Expect.equals(5, list.indexOf(15));
|
||||
/*@compile-error=unspecified*/ Expect.equals(9, list.indexOf(19));
|
||||
/*@compile-error=unspecified*/ Expect.equals(-1, list.indexOf(20));
|
||||
}
|
||||
|
||||
void testBadValues32() {
|
||||
var list = new Float32List(10);
|
||||
list[0] = 2.0;
|
||||
/*@compile-error=unspecified*/ list[0] = 2;
|
||||
/*@compile-error=unspecified*/ list[0] = "hello";
|
||||
}
|
||||
|
||||
void testIndexOf64() {
|
||||
var list = new Float64List(10);
|
||||
for (int i = 0; i < list.length; i++) {
|
||||
list[i] = i + 10.0;
|
||||
}
|
||||
/*@compile-error=unspecified*/ Expect.equals(0, list.indexOf(10));
|
||||
/*@compile-error=unspecified*/ Expect.equals(5, list.indexOf(15));
|
||||
/*@compile-error=unspecified*/ Expect.equals(9, list.indexOf(19));
|
||||
/*@compile-error=unspecified*/ Expect.equals(-1, list.indexOf(20));
|
||||
}
|
||||
|
||||
void testBadValues64() {
|
||||
var list = new Float64List(10);
|
||||
list[0] = 2.0;
|
||||
/*@compile-error=unspecified*/ list[0] = 2;
|
||||
/*@compile-error=unspecified*/ list[0] = "hello";
|
||||
}
|
||||
|
||||
main() {
|
||||
testIndexOf32();
|
||||
testIndexOf64();
|
||||
testBadValues32();
|
||||
testBadValues64();
|
||||
}
|
186
tests/standalone/float_array_test.dart
Normal file
186
tests/standalone/float_array_test.dart
Normal file
|
@ -0,0 +1,186 @@
|
|||
// 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.
|
||||
//
|
||||
// Dart test program for testing native float arrays.
|
||||
|
||||
// VMOptions=--optimization_counter_threshold=10 --no-background_compilation
|
||||
|
||||
// Library tag to be able to run in html test framework.
|
||||
library FloatArrayTest;
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
import 'dart:typed_data';
|
||||
|
||||
void testCreateFloat32Array() {
|
||||
Float32List floatArray;
|
||||
|
||||
floatArray = new Float32List(0);
|
||||
Expect.equals(0, floatArray.length);
|
||||
|
||||
floatArray = new Float32List(10);
|
||||
Expect.equals(10, floatArray.length);
|
||||
for (int i = 0; i < 10; i++) {
|
||||
Expect.equals(0.0, floatArray[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void testSetRange32() {
|
||||
Float32List floatArray = new Float32List(3);
|
||||
|
||||
List<double> list = [10.0, 11.0, 12.0];
|
||||
floatArray.setRange(0, 3, list);
|
||||
for (int i = 0; i < 3; i++) {
|
||||
Expect.equals(10 + i, floatArray[i]);
|
||||
}
|
||||
|
||||
floatArray[0] = 20.0;
|
||||
floatArray[1] = 21.0;
|
||||
floatArray[2] = 22.0;
|
||||
list.setRange(0, 3, floatArray);
|
||||
for (int i = 0; i < 3; i++) {
|
||||
Expect.equals(20 + i, list[i]);
|
||||
}
|
||||
|
||||
// 4.0e40 is larger than the largest representable float.
|
||||
floatArray.setRange(1, 3, const [8.0, 4.0e40]);
|
||||
Expect.equals(20, floatArray[0]);
|
||||
Expect.equals(8, floatArray[1]);
|
||||
Expect.equals(double.infinity, floatArray[2]);
|
||||
}
|
||||
|
||||
void testIndexOutOfRange32() {
|
||||
Float32List floatArray = new Float32List(3);
|
||||
List<double> list = const [0.0, 1.0, 2.0, 3.0];
|
||||
|
||||
Expect.throws(() {
|
||||
floatArray[5] = 2.0;
|
||||
});
|
||||
Expect.throws(() {
|
||||
floatArray.setRange(0, 4, list);
|
||||
});
|
||||
|
||||
Expect.throws(() {
|
||||
floatArray.setRange(3, 4, list);
|
||||
});
|
||||
}
|
||||
|
||||
void testIndexOf32() {
|
||||
var list = new Float32List(10);
|
||||
for (int i = 0; i < list.length; i++) {
|
||||
list[i] = i + 10.0;
|
||||
}
|
||||
Expect.equals(0, list.indexOf(10.0));
|
||||
Expect.equals(5, list.indexOf(15.0));
|
||||
Expect.equals(9, list.indexOf(19.0));
|
||||
Expect.equals(-1, list.indexOf(20.0));
|
||||
}
|
||||
|
||||
void testCreateFloat64Array() {
|
||||
Float64List floatArray;
|
||||
|
||||
floatArray = new Float64List(0);
|
||||
Expect.equals(0, floatArray.length);
|
||||
|
||||
floatArray = new Float64List(10);
|
||||
Expect.equals(10, floatArray.length);
|
||||
for (int i = 0; i < 10; i++) {
|
||||
Expect.equals(0.0, floatArray[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void testSetRange64() {
|
||||
Float64List floatArray = new Float64List(3);
|
||||
|
||||
List<double> list = [10.0, 11.0, 12.0];
|
||||
floatArray.setRange(0, 3, list);
|
||||
for (int i = 0; i < 3; i++) {
|
||||
Expect.equals(10 + i, floatArray[i]);
|
||||
}
|
||||
|
||||
floatArray[0] = 20.0;
|
||||
floatArray[1] = 21.0;
|
||||
floatArray[2] = 22.0;
|
||||
list.setRange(0, 3, floatArray);
|
||||
for (int i = 0; i < 3; i++) {
|
||||
Expect.equals(20 + i, list[i]);
|
||||
}
|
||||
|
||||
// Unlike Float32Array we can properly represent 4.0e40
|
||||
floatArray.setRange(1, 3, const [8.0, 4.0e40]);
|
||||
Expect.equals(20, floatArray[0]);
|
||||
Expect.equals(8, floatArray[1]);
|
||||
Expect.equals(4.0e40, floatArray[2]);
|
||||
}
|
||||
|
||||
void testIndexOutOfRange64() {
|
||||
Float64List floatArray = new Float64List(3);
|
||||
List<double> list = const [0.0, 1.0, 2.0, 3.0];
|
||||
|
||||
Expect.throws(() {
|
||||
floatArray[5] = 2.0;
|
||||
});
|
||||
Expect.throws(() {
|
||||
floatArray.setRange(0, 4, list);
|
||||
});
|
||||
|
||||
Expect.throws(() {
|
||||
floatArray.setRange(3, 4, list);
|
||||
});
|
||||
}
|
||||
|
||||
void testIndexOf64() {
|
||||
var list = new Float64List(10);
|
||||
for (int i = 0; i < list.length; i++) {
|
||||
list[i] = i + 10.0;
|
||||
}
|
||||
Expect.equals(0, list.indexOf(10.0));
|
||||
Expect.equals(5, list.indexOf(15.0));
|
||||
Expect.equals(9, list.indexOf(19.0));
|
||||
Expect.equals(-1, list.indexOf(20.0));
|
||||
}
|
||||
|
||||
storeIt32(Float32List a, int index, value) {
|
||||
a[index] = value;
|
||||
}
|
||||
|
||||
storeIt64(Float64List a, int index, value) {
|
||||
a[index] = value;
|
||||
}
|
||||
|
||||
testPolymorphicLoad(var list) {
|
||||
return list[0];
|
||||
}
|
||||
|
||||
main() {
|
||||
var a32 = new Float32List(5);
|
||||
for (int i = 0; i < 20; i++) {
|
||||
testCreateFloat32Array();
|
||||
testSetRange32();
|
||||
testIndexOutOfRange32();
|
||||
testIndexOf32();
|
||||
storeIt32(a32, 1, 2.0);
|
||||
testPolymorphicLoad(a32);
|
||||
}
|
||||
var a64 = new Float64List(5);
|
||||
for (int i = 0; i < 20; i++) {
|
||||
testCreateFloat64Array();
|
||||
testSetRange64();
|
||||
testIndexOutOfRange64();
|
||||
testIndexOf64();
|
||||
storeIt64(a64, 1, 2.0);
|
||||
testPolymorphicLoad(a64);
|
||||
}
|
||||
var f32x4 = new Float32x4List(5);
|
||||
for (int i = 0; i < 20; i++) {
|
||||
testPolymorphicLoad(f32x4);
|
||||
}
|
||||
|
||||
// Check optimized (inlined) version of []=
|
||||
Expect.throws(() {
|
||||
storeIt32(a32, 1, 2);
|
||||
});
|
||||
Expect.throws(() {
|
||||
storeIt64(a64, 1, 2);
|
||||
});
|
||||
}
|
41
tests/standalone/fragmentation_test.dart
Normal file
41
tests/standalone/fragmentation_test.dart
Normal file
|
@ -0,0 +1,41 @@
|
|||
// Copyright (c) 2017, 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.
|
||||
|
||||
// Deliberately fragment the heap and test that GC peformance does not
|
||||
// break down. See https://github.com/dart-lang/sdk/issues/29588
|
||||
// Normally runs in about 6-7 seconds on an x64 machine, using about 2.5Gbytes
|
||||
// of memory.
|
||||
//
|
||||
// This test is deliberately CPU-light and so it can make a lot of
|
||||
// progress before the concurrent sweepers are done sweeping the heap.
|
||||
// In that time there is no freelist and so the issue does not arise.
|
||||
// VMOptions=--no_concurrent_mark --no_concurrent_sweep
|
||||
// VMOptions=--no_concurrent_mark --concurrent_sweep
|
||||
// VMOptions=--no_concurrent_mark --use_compactor
|
||||
// VMOptions=--no_concurrent_mark --use_compactor --force_evacuation
|
||||
// VMOptions=--concurrent_mark --no_concurrent_sweep
|
||||
// VMOptions=--concurrent_mark --concurrent_sweep
|
||||
// VMOptions=--concurrent_mark --use_compactor
|
||||
// VMOptions=--concurrent_mark --use_compactor --force_evacuation
|
||||
// VMOptions=--scavenger_tasks=0
|
||||
// VMOptions=--scavenger_tasks=1
|
||||
// VMOptions=--scavenger_tasks=2
|
||||
// VMOptions=--scavenger_tasks=3
|
||||
|
||||
main() {
|
||||
final List<List?> arrays = [];
|
||||
// Fill up heap with alternate large-small items.
|
||||
for (int i = 0; i < 500000; i++) {
|
||||
arrays.add(new List<dynamic>.filled(260, null));
|
||||
arrays.add(new List<dynamic>.filled(1, null));
|
||||
}
|
||||
// Clear the large items so that the heap is full of 260-word gaps.
|
||||
for (int i = 0; i < arrays.length; i += 2) {
|
||||
arrays[i] = null;
|
||||
}
|
||||
// Allocate a lot of 300-word objects that don't fit in the gaps.
|
||||
for (int i = 0; i < 600000; i++) {
|
||||
arrays.add(new List<dynamic>.filled(300, null));
|
||||
}
|
||||
}
|
38
tests/standalone/fragmentation_typed_data_test.dart
Normal file
38
tests/standalone/fragmentation_typed_data_test.dart
Normal file
|
@ -0,0 +1,38 @@
|
|||
// Copyright (c) 2019, 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.
|
||||
|
||||
// See fragmentation_test.dart for more information.
|
||||
//
|
||||
// VMOptions=--no_concurrent_mark --no_concurrent_sweep
|
||||
// VMOptions=--no_concurrent_mark --concurrent_sweep
|
||||
// VMOptions=--no_concurrent_mark --use_compactor
|
||||
// VMOptions=--no_concurrent_mark --use_compactor --force_evacuation
|
||||
// VMOptions=--concurrent_mark --no_concurrent_sweep
|
||||
// VMOptions=--concurrent_mark --concurrent_sweep
|
||||
// VMOptions=--concurrent_mark --use_compactor
|
||||
// VMOptions=--concurrent_mark --use_compactor --force_evacuation
|
||||
|
||||
import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
|
||||
main() {
|
||||
// We have less memory available on the Android testing devices, and if we
|
||||
// allocate to much the kernel may summarily terminate us.
|
||||
final double factor = Platform.isAndroid ? 0.5 : 1.0;
|
||||
|
||||
final List<List?> arrays = [];
|
||||
// Fill up heap with alternate large-small items.
|
||||
for (int i = 0; i < 500000 * factor; i++) {
|
||||
arrays.add(new Uint32List(260));
|
||||
arrays.add(new Uint32List(1));
|
||||
}
|
||||
// Clear the large items so the heap has large gaps.
|
||||
for (int i = 0; i < arrays.length; i += 2) {
|
||||
arrays[i] = null;
|
||||
}
|
||||
// Allocate a lot of large items which don't fit in the gaps created above.
|
||||
for (int i = 0; i < 600000 * factor; i++) {
|
||||
arrays.add(new Uint32List(300));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"configVersion": 2,
|
||||
"packages": [
|
||||
{
|
||||
"name": "simple",
|
||||
"rootUri": "../the_packages/simple"
|
||||
}
|
||||
]
|
||||
}
|
1
tests/standalone/http_launch_data/.packages
Normal file
1
tests/standalone/http_launch_data/.packages
Normal file
|
@ -0,0 +1 @@
|
|||
simple:the_packages/simple
|
10
tests/standalone/http_launch_data/http_isolate_main.dart
Normal file
10
tests/standalone/http_launch_data/http_isolate_main.dart
Normal file
|
@ -0,0 +1,10 @@
|
|||
// Copyright (c) 2013, 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 'dart:isolate';
|
||||
|
||||
main(List<String> args, SendPort replyTo) {
|
||||
var data = args[0];
|
||||
replyTo.send(data);
|
||||
}
|
11
tests/standalone/http_launch_data/http_launch_main.dart
Normal file
11
tests/standalone/http_launch_data/http_launch_main.dart
Normal file
|
@ -0,0 +1,11 @@
|
|||
// Copyright (c) 2013, 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.
|
||||
|
||||
library http_launch_main;
|
||||
|
||||
import 'package:simple/simple.dart';
|
||||
|
||||
main() {
|
||||
print(getSimpleString());
|
||||
}
|
18
tests/standalone/http_launch_data/http_spawn_main.dart
Normal file
18
tests/standalone/http_launch_data/http_spawn_main.dart
Normal file
|
@ -0,0 +1,18 @@
|
|||
// Copyright (c) 2013, 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.
|
||||
|
||||
library http_launch_main;
|
||||
|
||||
import 'dart:isolate';
|
||||
import 'dart:io';
|
||||
|
||||
main(List<String> arguments) {
|
||||
int port = int.parse(arguments[0]);
|
||||
ReceivePort receivePort = new ReceivePort();
|
||||
Isolate.spawnUri(Uri.parse('http://127.0.0.1:$port/http_isolate_main.dart'),
|
||||
['hello'], receivePort.sendPort);
|
||||
receivePort.first.then((response) {
|
||||
print(response);
|
||||
});
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
// Copyright (c) 2013, 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.
|
||||
|
||||
library simple;
|
||||
|
||||
String getSimpleString() => 'hello';
|
112
tests/standalone/http_launch_test.dart
Normal file
112
tests/standalone/http_launch_test.dart
Normal file
|
@ -0,0 +1,112 @@
|
|||
// Copyright (c) 2013, 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=
|
||||
// VMOptions=--short_socket_read
|
||||
// VMOptions=--short_socket_write
|
||||
// VMOptions=--short_socket_read --short_socket_write
|
||||
// OtherResources=http_launch_data/http_isolate_main.dart
|
||||
// OtherResources=http_launch_data/http_launch_main.dart
|
||||
// OtherResources=http_launch_data/http_spawn_main.dart
|
||||
// OtherResources=http_launch_data/the_packages/simple/simple.dart
|
||||
// OtherResources=http_launch_data/.packages
|
||||
//
|
||||
// Test:
|
||||
// *) Launching a script fetched over HTTP.
|
||||
// *) Importing a library fetched over HTTP.
|
||||
// *) Automatically resolving package_root when script is fetched over HTTP.
|
||||
// *) Spawning a URI over HTTP.
|
||||
|
||||
library http_launch_test;
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
import 'package:expect/expect.dart';
|
||||
|
||||
String pathToExecutable = Platform.executable;
|
||||
List<String> executableArguments = Platform.executableArguments
|
||||
.where((arg) => !arg.startsWith('--packages='))
|
||||
.toList();
|
||||
Uri pathOfData = Platform.script.resolve('http_launch_data/');
|
||||
late int port;
|
||||
|
||||
_sendNotFound(HttpResponse response) {
|
||||
response.statusCode = HttpStatus.notFound;
|
||||
response.close();
|
||||
}
|
||||
|
||||
handleRequest(HttpRequest request) {
|
||||
final String path = request.uri.path.substring(1);
|
||||
final Uri requestPath = pathOfData.resolve(path);
|
||||
final File file = new File(requestPath.toFilePath());
|
||||
file.exists().then((bool found) {
|
||||
if (found) {
|
||||
file.openRead().cast<List<int>>().pipe(request.response).catchError((e) {
|
||||
_sendNotFound(request.response);
|
||||
});
|
||||
} else {
|
||||
_sendNotFound(request.response);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
serverRunning(HttpServer server) {
|
||||
port = server.port;
|
||||
server.listen(handleRequest);
|
||||
Future<ProcessResult> no_http_run = Process.run(
|
||||
pathToExecutable,
|
||||
[]
|
||||
..addAll(executableArguments)
|
||||
..add(pathOfData.resolve('http_launch_main.dart').toFilePath()));
|
||||
Future<ProcessResult> http_run = Process.run(
|
||||
pathToExecutable,
|
||||
[]
|
||||
..addAll(executableArguments)
|
||||
..add('http://127.0.0.1:$port/http_launch_main.dart'));
|
||||
Future<ProcessResult> http_pkg_root_run = Process.run(
|
||||
pathToExecutable,
|
||||
[]
|
||||
..addAll(executableArguments)
|
||||
..addAll(['http://127.0.0.1:$port/http_launch_main.dart']));
|
||||
Future<ProcessResult> isolate_run = Process.run(
|
||||
pathToExecutable,
|
||||
[]
|
||||
..addAll(executableArguments)
|
||||
..addAll(['http://127.0.0.1:$port/http_spawn_main.dart', '$port']));
|
||||
Future<List<ProcessResult>> results =
|
||||
Future.wait([no_http_run, http_run, http_pkg_root_run, isolate_run]);
|
||||
results.then((results) {
|
||||
// Close server.
|
||||
server.close();
|
||||
// Check results.
|
||||
checkResults(results);
|
||||
});
|
||||
}
|
||||
|
||||
checkResults(List<ProcessResult> results) {
|
||||
Expect.equals(4, results.length);
|
||||
// Exited cleanly.
|
||||
for (int i = 0; i < results.length; i++) {
|
||||
ProcessResult result = results[i];
|
||||
if (result.exitCode != 0) {
|
||||
print("Exit code for process $i = ${result.exitCode}");
|
||||
print("---stdout:---\n${result.stdout}");
|
||||
print("---stderr:---\n${result.stderr}\n---");
|
||||
}
|
||||
Expect.equals(0, result.exitCode);
|
||||
}
|
||||
String stdout = results[0].stdout;
|
||||
// Output is the string 'hello'. Use startsWith to avoid new line differences.
|
||||
if (!stdout.startsWith('hello')) {
|
||||
print("---- stdout of remote process:\n$stdout\n----");
|
||||
}
|
||||
Expect.isTrue(stdout.startsWith('hello'));
|
||||
// Same output from all three process runs.
|
||||
for (int i = 0; i < results.length; i++) {
|
||||
Expect.equals(stdout, results[i].stdout);
|
||||
}
|
||||
}
|
||||
|
||||
main() {
|
||||
HttpServer.bind(InternetAddress.loopbackIPv4, 0).then(serverRunning);
|
||||
}
|
33
tests/standalone/int_array_deopt.dart
Normal file
33
tests/standalone/int_array_deopt.dart
Normal file
|
@ -0,0 +1,33 @@
|
|||
// Copyright (c) 2013, 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.
|
||||
//
|
||||
// Dart deoptimization of Uint32Array and Int32Array loads.
|
||||
|
||||
import 'dart:typed_data';
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
loadI32(a) => a[0] + 1;
|
||||
loadUi32(a) => a[0] + 1;
|
||||
|
||||
main() {
|
||||
var i32 = new Int32List(10);
|
||||
var ui32 = new Uint32List(10);
|
||||
i32[0] = ui32[0] = 8;
|
||||
// Optimize loadI32 and LoadUi32 for Smi result of indexed load.
|
||||
for (int i = 0; i < 2000; i++) {
|
||||
Expect.equals(9, loadI32(i32));
|
||||
Expect.equals(9, loadUi32(ui32));
|
||||
}
|
||||
// On ia32, deoptimize when attempting to load a value that exceeds
|
||||
// Smi range.
|
||||
i32[0] = ui32[0] = 2147483647;
|
||||
Expect.equals(2147483648, loadI32(i32));
|
||||
Expect.equals(2147483648, loadUi32(ui32));
|
||||
// Reoptimize again, but this time assume mixed Smi/Mint results
|
||||
i32[0] = ui32[0] = 10;
|
||||
for (int i = 0; i < 2000; i++) {
|
||||
Expect.equals(11, loadI32(i32));
|
||||
Expect.equals(11, loadUi32(ui32));
|
||||
}
|
||||
}
|
24
tests/standalone/int_array_load_elimination_test.dart
Normal file
24
tests/standalone/int_array_load_elimination_test.dart
Normal file
|
@ -0,0 +1,24 @@
|
|||
// 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.
|
||||
//
|
||||
// Test correct load elimination for scalar lists.
|
||||
|
||||
// TODO: remove once bug 2264 fixed.
|
||||
library int_array_load_elimination;
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
import 'dart:typed_data';
|
||||
|
||||
void testUint16() {
|
||||
Uint16List intArray = new Uint16List(1);
|
||||
intArray[0] = -1;
|
||||
var x = intArray[0];
|
||||
Expect.equals(65535, x);
|
||||
}
|
||||
|
||||
main() {
|
||||
for (int i = 0; i < 2000; i++) {
|
||||
testUint16();
|
||||
}
|
||||
}
|
139
tests/standalone/int_array_test.dart
Normal file
139
tests/standalone/int_array_test.dart
Normal file
|
@ -0,0 +1,139 @@
|
|||
// 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.
|
||||
//
|
||||
// Dart test program for testing native int arrays.
|
||||
|
||||
// Library tag to be able to run in html test framework.
|
||||
library IntArrayTest;
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
import 'dart:typed_data';
|
||||
|
||||
void testInt16() {
|
||||
Int16List intArray = new Int16List(4);
|
||||
intArray[0] = 0;
|
||||
intArray[1] = -1;
|
||||
intArray[2] = -2;
|
||||
intArray[3] = -3;
|
||||
for (int i = 0; i < intArray.length; i++) {
|
||||
intArray[i]++;
|
||||
}
|
||||
var x = intArray[0];
|
||||
var y = intArray[1];
|
||||
var z = intArray[2];
|
||||
var w = intArray[3];
|
||||
Expect.equals(1, x);
|
||||
Expect.equals(0, y);
|
||||
Expect.equals(-1, z);
|
||||
Expect.equals(-2, w);
|
||||
var t = y + 1;
|
||||
intArray[0] = t;
|
||||
Expect.equals(t, intArray[0]);
|
||||
}
|
||||
|
||||
void testUint16() {
|
||||
Uint16List intArray = new Uint16List(4);
|
||||
intArray[0] = 0;
|
||||
intArray[1] = 1;
|
||||
intArray[2] = 2;
|
||||
intArray[3] = 3;
|
||||
for (int i = 0; i < intArray.length; i++) {
|
||||
intArray[i]--;
|
||||
}
|
||||
var x = intArray[0];
|
||||
var y = intArray[1];
|
||||
var z = intArray[2];
|
||||
var w = intArray[3];
|
||||
Expect.equals(65535, x);
|
||||
Expect.equals(0, y);
|
||||
Expect.equals(1, z);
|
||||
Expect.equals(2, w);
|
||||
var t = y + 1;
|
||||
intArray[0] = t;
|
||||
Expect.equals(t, intArray[0]);
|
||||
}
|
||||
|
||||
void testInt32ToSmi() {
|
||||
Int32List intArray;
|
||||
|
||||
intArray = new Int32List(4);
|
||||
intArray[0] = 1073741823; // SmiMax
|
||||
intArray[1] = -1073741824; // SmiMin
|
||||
intArray[2] = 1073741824; // SmiMax+1
|
||||
intArray[3] = -1073741825; // SmiMin-1
|
||||
var x = intArray[0];
|
||||
var y = intArray[1];
|
||||
var z = intArray[2];
|
||||
var w = intArray[3];
|
||||
Expect.equals(1073741823, x);
|
||||
Expect.equals(-1073741824, y);
|
||||
Expect.equals(1073741824, z);
|
||||
Expect.equals(-1073741825, w);
|
||||
}
|
||||
|
||||
void testUint32ToSmi() {
|
||||
Uint32List intArray;
|
||||
|
||||
intArray = new Uint32List(4);
|
||||
intArray[0] = 1073741823; // SmiMax
|
||||
intArray[1] = -1; // 0xFFFFFFFF : 4294967295
|
||||
intArray[2] = 1073741830; // SmiMax+7
|
||||
intArray[3] = -1073741825; // 0xbfffffff : 3221225471
|
||||
var x = intArray[0];
|
||||
var y = intArray[1];
|
||||
var z = intArray[2];
|
||||
var w = intArray[3];
|
||||
Expect.equals(1073741823, x);
|
||||
Expect.equals(4294967295, y);
|
||||
Expect.equals(1073741830, z);
|
||||
Expect.equals(3221225471, w);
|
||||
}
|
||||
|
||||
void testInt64ToSmi() {
|
||||
Int64List intArray;
|
||||
|
||||
intArray = new Int64List(4);
|
||||
intArray[0] = 4611686018427387903; // SmiMax
|
||||
intArray[1] = -4611686018427387904; // SmiMin
|
||||
intArray[2] = 4611686018427387904; // SmiMax+1
|
||||
intArray[3] = -4611686018427387905; // SmiMin-1
|
||||
var x = intArray[0];
|
||||
var y = intArray[1];
|
||||
var z = intArray[2];
|
||||
var w = intArray[3];
|
||||
Expect.equals(4611686018427387903, x);
|
||||
Expect.equals(-4611686018427387904, y);
|
||||
Expect.equals(4611686018427387904, z);
|
||||
Expect.equals(-4611686018427387905, w);
|
||||
}
|
||||
|
||||
void testUint64ToSmi() {
|
||||
Uint64List intArray;
|
||||
|
||||
intArray = new Uint64List(4);
|
||||
intArray[0] = 4611686018427387903; // SmiMax
|
||||
intArray[1] = -1; // 0xFFFFFFFFFFFFFFFF : 18446744073709551615
|
||||
intArray[2] = 4611686018427387904; // SmiMax+1
|
||||
intArray[3] = -9223372036854775808;
|
||||
var x = intArray[0];
|
||||
var y = intArray[1];
|
||||
var z = intArray[2];
|
||||
var w = intArray[3];
|
||||
Expect.equals(4611686018427387903, x);
|
||||
Expect.equals(-1, y);
|
||||
Expect.equals(4611686018427387904, z);
|
||||
Expect.equals(-9223372036854775808, w);
|
||||
}
|
||||
|
||||
main() {
|
||||
testUint64ToSmi();
|
||||
for (int i = 0; i < 2000; i++) {
|
||||
testInt16();
|
||||
testUint16();
|
||||
testInt32ToSmi();
|
||||
testUint32ToSmi();
|
||||
testInt64ToSmi();
|
||||
testUint64ToSmi();
|
||||
}
|
||||
}
|
42
tests/standalone/int_list_test.dart
Normal file
42
tests/standalone/int_list_test.dart
Normal file
|
@ -0,0 +1,42 @@
|
|||
// Copyright (c) 2014, 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.
|
||||
//
|
||||
// Dart Mint representations and type propagation issue.
|
||||
// Testing Int32List and Uint32List loads.
|
||||
//
|
||||
// VMOptions=--optimization-counter-threshold=5 --no-use-osr --no-background-compilation
|
||||
|
||||
import 'dart:typed_data';
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
main() {
|
||||
var a = new Uint32List(100);
|
||||
a[2] = 3;
|
||||
var res = sumIt1(a, 2);
|
||||
Expect.equals(3 * 10, res);
|
||||
res = sumIt1(a, 2);
|
||||
Expect.equals(3 * 10, res);
|
||||
var a1 = new Int32List(100);
|
||||
a1[2] = 3;
|
||||
res = sumIt2(a1, 2);
|
||||
Expect.equals(3 * 10, res);
|
||||
res = sumIt2(a1, 2);
|
||||
Expect.equals(3 * 10, res);
|
||||
}
|
||||
|
||||
sumIt1(Uint32List a, int n) {
|
||||
var sum = 0;
|
||||
for (int i = 0; i < 10; i++) {
|
||||
sum += a[n];
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
sumIt2(Int32List a, int n) {
|
||||
var sum = 0;
|
||||
for (int i = 0; i < 10; i++) {
|
||||
sum += a[n];
|
||||
}
|
||||
return sum;
|
||||
}
|
80
tests/standalone/left_shift_bit_and_op_test.dart
Normal file
80
tests/standalone/left_shift_bit_and_op_test.dart
Normal file
|
@ -0,0 +1,80 @@
|
|||
// Copyright (c) 2013, 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.
|
||||
//
|
||||
// Tests optimizing (a << b) & c if c is a Smi constant.
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
main() {
|
||||
checkshiftAnd32();
|
||||
checkShiftAnd64();
|
||||
// Optimize shiftAnd32.
|
||||
for (int i = 0; i < 10000; i++) {
|
||||
A.shiftAnd32(12, 17);
|
||||
A.shiftAnd64(12, 17);
|
||||
Expect.equals(72, A.multipleConstantUses(3, 4));
|
||||
Expect.equals(34493956096, A.multipleShiftUse(134742016, 8));
|
||||
}
|
||||
checkshiftAnd32();
|
||||
checkShiftAnd64();
|
||||
|
||||
Expect.throws(() => A.shiftAnd32(12, -5));
|
||||
|
||||
// Check environment dependency.
|
||||
final a = new A(), b = new B();
|
||||
for (var i = 0; i < 10000; i++) {
|
||||
Expect.equals(0, bar(a));
|
||||
}
|
||||
Expect.equals(4294967296, bar(b));
|
||||
}
|
||||
|
||||
checkshiftAnd32() {
|
||||
Expect.equals(1572864, A.shiftAnd32(12, 17));
|
||||
Expect.equals(12, A.shiftAnd32(12, 0));
|
||||
Expect.equals(285212672, A.shiftAnd32(16779392, 17));
|
||||
}
|
||||
|
||||
checkShiftAnd64() {
|
||||
Expect.equals(1125936481173504, A.shiftAnd64(4611694814806147072, 7));
|
||||
}
|
||||
|
||||
class A {
|
||||
static const int MASK_32 = (1 << 30) - 1;
|
||||
static const int MASK_64 = (1 << 62) - 1;
|
||||
|
||||
static shiftAnd32(a, c) {
|
||||
return (a << c) & MASK_32;
|
||||
}
|
||||
|
||||
static shiftAnd64(a, c) {
|
||||
return (a << c) & MASK_64;
|
||||
}
|
||||
|
||||
static multipleConstantUses(a, c) {
|
||||
var j = (a << c) & 0xFF;
|
||||
var k = (a << 3) & 0xFF;
|
||||
return j + k;
|
||||
}
|
||||
|
||||
// Make sure that left shift is nor marked as truncating.
|
||||
static multipleShiftUse(a, c) {
|
||||
var y = (a << c);
|
||||
var x = y & 0x7F;
|
||||
return y + x;
|
||||
}
|
||||
|
||||
foo(x) {
|
||||
return x & 0xf;
|
||||
}
|
||||
}
|
||||
|
||||
class B {
|
||||
foo(x) {
|
||||
return x;
|
||||
}
|
||||
}
|
||||
|
||||
bar(o) {
|
||||
return o.foo(1 << 32);
|
||||
}
|
9
tests/standalone/link_natives_lazily_test.dart
Normal file
9
tests/standalone/link_natives_lazily_test.dart
Normal file
|
@ -0,0 +1,9 @@
|
|||
// Copyright (c) 2016, 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=--link_natives_lazily
|
||||
|
||||
main() {
|
||||
print("Okay");
|
||||
}
|
21
tests/standalone/map_insert_remove_oom_test.dart
Normal file
21
tests/standalone/map_insert_remove_oom_test.dart
Normal file
|
@ -0,0 +1,21 @@
|
|||
// Copyright (c) 2015, 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=--old_gen_heap_size=12
|
||||
//
|
||||
// Notice we set the old gen heap size to 12 MB, which seems to be the minimum
|
||||
// (in debug mode) to not cause us run OOM during isolate initialization. The
|
||||
// problem here is that we pre-allocate certain exceptions, e.g. NullThrownError
|
||||
// during isolate initialization, but if we have an allocation failure before
|
||||
// that, we end up running into a recursive allocate/throw loop.
|
||||
//
|
||||
// Test that compaction does occur on repeated add/remove.
|
||||
|
||||
main() {
|
||||
var x = {};
|
||||
for (int i = 0; i < 1000000; i++) {
|
||||
x[i] = 10;
|
||||
x.remove(i);
|
||||
}
|
||||
}
|
108
tests/standalone/medium_integer_test.dart
Normal file
108
tests/standalone/medium_integer_test.dart
Normal file
|
@ -0,0 +1,108 @@
|
|||
// Copyright (c) 2011, 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.
|
||||
// Testing Mints. Note that the tests may not work on 64-bit machines,
|
||||
// as Smi's would be used to represent many of the numbers.
|
||||
|
||||
library MediumIntegerTest;
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
class MediumIntegerTest {
|
||||
static int getMint() {
|
||||
return 1234567890123456789;
|
||||
}
|
||||
|
||||
static testSmiOverflow() {
|
||||
int a = 1073741823;
|
||||
int b = 1073741822;
|
||||
Expect.equals(2147483645, a + b);
|
||||
Expect.equals(1152921501385621506, a * b);
|
||||
Expect.equals(-2147483645, -a - b);
|
||||
}
|
||||
|
||||
static testMintAdd() {
|
||||
// Mint and Smi.
|
||||
var a = 1234567890123456789;
|
||||
var b = 2;
|
||||
Expect.equals(1234567890123456791, a + b);
|
||||
Expect.equals(1234567890123456791, b + a);
|
||||
a = 9223372036854775807;
|
||||
Expect.equals(-9223372036854775808, a + 1);
|
||||
|
||||
// Mint and Mint.
|
||||
a = 100000000000000001;
|
||||
Expect.equals(200000000000000002, a + a);
|
||||
a = 9223372036854775800;
|
||||
b = 1000000000000000000;
|
||||
Expect.equals(-8223372036854775816, a + b);
|
||||
|
||||
// Mint and double.
|
||||
var da = 100000000000.0;
|
||||
b = 100000000000;
|
||||
Expect.equals(200000000000.0, da + b);
|
||||
Expect.equals(200000000000.0, b + da);
|
||||
}
|
||||
|
||||
static testMintSub() {
|
||||
// Mint and Smi.
|
||||
var a = 1234567890123456789;
|
||||
var b = 2;
|
||||
Expect.equals(1234567890123456787, a - b);
|
||||
a = -9223372036854775808;
|
||||
Expect.equals(9223372036854775807, a - 1);
|
||||
|
||||
// Mint and Mint.
|
||||
a = 1234567890123456789;
|
||||
b = 1000000000000000000;
|
||||
Expect.equals(234567890123456789, a - b);
|
||||
a = -9223372036854775808;
|
||||
b = 1000000000000000000;
|
||||
Expect.equals(8223372036854775808, a - b);
|
||||
}
|
||||
|
||||
static testMintDiv() {
|
||||
// Mint and Smi.
|
||||
var a = 1234567890123456788;
|
||||
var b = 2;
|
||||
Expect.equals(617283945061728394.0, a / b);
|
||||
}
|
||||
|
||||
static testMintMul() {
|
||||
// Mint and Smi.
|
||||
var a = 4611686018427387904;
|
||||
var b = 10;
|
||||
Expect.equals(-9223372036854775808, a * b);
|
||||
b = 1000000000000000000;
|
||||
Expect.equals(0, a * b);
|
||||
}
|
||||
|
||||
static testMintAnd(mint) {
|
||||
// Issue 1845.
|
||||
final int t = 0;
|
||||
var res = mint & (t - 1);
|
||||
Expect.equals(mint, res);
|
||||
}
|
||||
|
||||
static void testMain() {
|
||||
Expect.equals(1234567890123456789, getMint());
|
||||
testSmiOverflow();
|
||||
testMintAdd();
|
||||
testMintSub();
|
||||
testMintMul();
|
||||
testMintDiv();
|
||||
testMintAnd(-1925149952);
|
||||
testMintAnd(1925149952);
|
||||
testMintAnd(0x100000001);
|
||||
var a = 100000000000;
|
||||
var b = 100000000001;
|
||||
Expect.equals(false, a.hashCode == b.hashCode);
|
||||
Expect.equals(true, a.hashCode == (b - 1).hashCode);
|
||||
}
|
||||
}
|
||||
|
||||
main() {
|
||||
for (int i = 0; i < 4000; i++) {
|
||||
MediumIntegerTest.testMain();
|
||||
}
|
||||
}
|
9
tests/standalone/no_allow_absolute_addresses_test.dart
Normal file
9
tests/standalone/no_allow_absolute_addresses_test.dart
Normal file
|
@ -0,0 +1,9 @@
|
|||
// Copyright (c) 2016, 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=--no_allow_absolute_addresses
|
||||
|
||||
main() {
|
||||
print("Okay");
|
||||
}
|
9
tests/standalone/no_lazy_dispatchers_test.dart
Normal file
9
tests/standalone/no_lazy_dispatchers_test.dart
Normal file
|
@ -0,0 +1,9 @@
|
|||
// Copyright (c) 2016, 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=--no_lazy_dispatchers
|
||||
|
||||
main() {
|
||||
print("Okay");
|
||||
}
|
9
tests/standalone/no_profiler_test.dart
Normal file
9
tests/standalone/no_profiler_test.dart
Normal file
|
@ -0,0 +1,9 @@
|
|||
// Copyright (c) 2016, 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=--no_profiler
|
||||
|
||||
main() {
|
||||
print("Okay");
|
||||
}
|
9
tests/standalone/no_support_ast_printer_test.dart
Normal file
9
tests/standalone/no_support_ast_printer_test.dart
Normal file
|
@ -0,0 +1,9 @@
|
|||
// Copyright (c) 2016, 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=--no-support_ast_printer
|
||||
|
||||
main() {
|
||||
print("Okay");
|
||||
}
|
9
tests/standalone/no_support_debugger_test.dart
Normal file
9
tests/standalone/no_support_debugger_test.dart
Normal file
|
@ -0,0 +1,9 @@
|
|||
// Copyright (c) 2016, 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=--no-support_debugger
|
||||
|
||||
main() {
|
||||
print("Okay");
|
||||
}
|
9
tests/standalone/no_support_disassembler_test.dart
Normal file
9
tests/standalone/no_support_disassembler_test.dart
Normal file
|
@ -0,0 +1,9 @@
|
|||
// Copyright (c) 2016, 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=--no_support_disassembler
|
||||
|
||||
main() {
|
||||
print("Okay");
|
||||
}
|
9
tests/standalone/no_support_il_printer_test.dart
Normal file
9
tests/standalone/no_support_il_printer_test.dart
Normal file
|
@ -0,0 +1,9 @@
|
|||
// Copyright (c) 2016, 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=--no-support_il_printer
|
||||
|
||||
main() {
|
||||
print("Okay");
|
||||
}
|
9
tests/standalone/no_support_service_test.dart
Normal file
9
tests/standalone/no_support_service_test.dart
Normal file
|
@ -0,0 +1,9 @@
|
|||
// Copyright (c) 2016, 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=--no-support_service
|
||||
|
||||
main() {
|
||||
print("Okay");
|
||||
}
|
9
tests/standalone/no_support_timeline_test.dart
Normal file
9
tests/standalone/no_support_timeline_test.dart
Normal file
|
@ -0,0 +1,9 @@
|
|||
// Copyright (c) 2016, 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=--no-support_timeline
|
||||
|
||||
main() {
|
||||
print("Okay");
|
||||
}
|
30
tests/standalone/number_identity_test.dart
Normal file
30
tests/standalone/number_identity_test.dart
Normal file
|
@ -0,0 +1,30 @@
|
|||
// 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.
|
||||
// Dart test program for testing params.
|
||||
//
|
||||
// Tests 'identical' for cases that not supported in dart2js (bigint,
|
||||
// disambiguation int/double).
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
main() {
|
||||
for (int i = 0; i < 1000; i++) testNumberIdentity();
|
||||
}
|
||||
|
||||
testNumberIdentity() {
|
||||
const int smi = 8;
|
||||
const int mint = 9223372036854775807;
|
||||
const double dbl = 8.0;
|
||||
// No int/double differences in dart2js.
|
||||
var a = smi + 0;
|
||||
Expect.isFalse(identical(a, dbl));
|
||||
var c = dbl + 0.0;
|
||||
Expect.isFalse(identical(c, smi));
|
||||
|
||||
a = mint;
|
||||
var b = a + 0;
|
||||
Expect.isTrue(identical(a, b));
|
||||
b = a + 1;
|
||||
Expect.isFalse(identical(a, b)); // Fails with dart2js.
|
||||
}
|
49
tests/standalone/oom_error_stacktrace_test.dart
Normal file
49
tests/standalone/oom_error_stacktrace_test.dart
Normal file
|
@ -0,0 +1,49 @@
|
|||
// Copyright (c) 2013, 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.
|
||||
// Dart test program for testing throw statement
|
||||
// VMOptions=--old_gen_heap_size=512
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
class Helper1 {
|
||||
static int func1() {
|
||||
return func2();
|
||||
}
|
||||
|
||||
static int func2() {
|
||||
return func3();
|
||||
}
|
||||
|
||||
static int func3() {
|
||||
return func4();
|
||||
}
|
||||
|
||||
static int func4() {
|
||||
var i = 0;
|
||||
try {
|
||||
i = 10;
|
||||
func5();
|
||||
} on OutOfMemoryError catch (e) {
|
||||
i = 100;
|
||||
Expect.isNull(e.stackTrace, "OOM should not have a stackTrace on throw");
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
static List func5() {
|
||||
// Cause an OOM(out of memory) exception.
|
||||
var l1 = new List<dynamic>.filled(268435455, null);
|
||||
return l1;
|
||||
}
|
||||
}
|
||||
|
||||
class OOMErrorStackTraceTest {
|
||||
static testMain() {
|
||||
Expect.equals(100, Helper1.func1());
|
||||
}
|
||||
}
|
||||
|
||||
main() {
|
||||
OOMErrorStackTraceTest.testMain();
|
||||
}
|
17
tests/standalone/out_of_memory_test.dart
Normal file
17
tests/standalone/out_of_memory_test.dart
Normal file
|
@ -0,0 +1,17 @@
|
|||
// 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=--old_gen_heap_size=512
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
void main() {
|
||||
var number_of_ints = 134000000;
|
||||
var exception_thrown = false;
|
||||
try {
|
||||
List<int> buf = new List<int>.filled(number_of_ints, -1);
|
||||
} on OutOfMemoryError catch (exc) {
|
||||
exception_thrown = true;
|
||||
}
|
||||
Expect.isTrue(exception_thrown);
|
||||
}
|
10
tests/standalone/package/invalid_uri_test.dart
Normal file
10
tests/standalone/package/invalid_uri_test.dart
Normal file
|
@ -0,0 +1,10 @@
|
|||
// 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.
|
||||
|
||||
library invalid_uri_test;
|
||||
|
||||
// Should not contain "//".
|
||||
import 'package://lib1.dart'; //# 01: compile-time error
|
||||
|
||||
void main() {}
|
13
tests/standalone/package/package1_test.dart
Normal file
13
tests/standalone/package/package1_test.dart
Normal file
|
@ -0,0 +1,13 @@
|
|||
// 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.
|
||||
|
||||
// Packages=none
|
||||
|
||||
library package1_test;
|
||||
|
||||
import 'package:package1.dart' as p1;
|
||||
|
||||
main() {
|
||||
p1.main();
|
||||
}
|
49
tests/standalone/package/package_isolate_test.dart
Normal file
49
tests/standalone/package/package_isolate_test.dart
Normal file
|
@ -0,0 +1,49 @@
|
|||
// 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.
|
||||
|
||||
library package_isolate_test;
|
||||
|
||||
import 'packages/shared.dart' as shared;
|
||||
import 'dart:isolate';
|
||||
import '../../../pkg/async_helper/lib/async_helper.dart';
|
||||
import '../../../pkg/expect/lib/expect.dart';
|
||||
|
||||
expectResponse() {
|
||||
asyncStart();
|
||||
var receivePort = new ReceivePort();
|
||||
receivePort.first.then((msg) {
|
||||
Expect.equals('isolate', msg);
|
||||
Expect.equals('main', shared.output);
|
||||
asyncEnd();
|
||||
});
|
||||
return receivePort;
|
||||
}
|
||||
|
||||
void main() {
|
||||
{
|
||||
var replyPort = expectResponse().sendPort;
|
||||
shared.output = 'main';
|
||||
Isolate.spawn(isolate_main, replyPort);
|
||||
}
|
||||
|
||||
{
|
||||
// Package in spawnUri() of sibling file.
|
||||
var replyPort = expectResponse().sendPort;
|
||||
shared.output = 'main';
|
||||
Isolate.spawnUri(Uri.parse('sibling_isolate.dart'), [], replyPort);
|
||||
}
|
||||
|
||||
{
|
||||
// Package in spawnUri() of file in folder.
|
||||
var replyPort = expectResponse().sendPort;
|
||||
shared.output = 'main';
|
||||
Isolate.spawnUri(
|
||||
Uri.parse('test_folder/folder_isolate.dart'), [], replyPort);
|
||||
}
|
||||
}
|
||||
|
||||
void isolate_main(SendPort replyTo) {
|
||||
shared.output = 'isolate';
|
||||
replyTo.send(shared.output);
|
||||
}
|
21
tests/standalone/package/package_test.dart
Normal file
21
tests/standalone/package/package_test.dart
Normal file
|
@ -0,0 +1,21 @@
|
|||
// 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.
|
||||
|
||||
// Packages=none
|
||||
|
||||
library package_test;
|
||||
|
||||
import 'package:lib1.dart';
|
||||
import 'package:shared.dart';
|
||||
|
||||
void main() {
|
||||
output = 'main';
|
||||
// Call an imported lib, which will in turn call some others.
|
||||
lib1();
|
||||
|
||||
// Make sure they were all reached successfully.
|
||||
if (output != 'main|lib1|lib2|lib3') {
|
||||
throw new Error("libraries were not reached successfully");
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
foo:foo/
|
|
@ -0,0 +1,9 @@
|
|||
// Copyright (c) 2015, 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.
|
||||
|
||||
// Packages=none
|
||||
|
||||
library both_dir_and_file_noimports_test;
|
||||
|
||||
main() {}
|
|
@ -0,0 +1,7 @@
|
|||
// Copyright (c) 2015, 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.
|
||||
|
||||
library foo;
|
||||
|
||||
String bar = 'good';
|
|
@ -0,0 +1,15 @@
|
|||
// Copyright (c) 2015, 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.
|
||||
|
||||
// Packages=none
|
||||
|
||||
library prefers_packages_file_test;
|
||||
|
||||
import 'package:foo/foo.dart' as foo;
|
||||
|
||||
main() {
|
||||
if (foo.bar != 'good') {
|
||||
throw new Exception('package "foo" was not resolved correctly');
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
// Copyright (c) 2015, 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.
|
||||
|
||||
// Packages=none
|
||||
|
||||
library empty_packages_file_discovery_test;
|
||||
|
||||
import 'package:foo/foo.dart';
|
||||
|
||||
main() {}
|
|
@ -0,0 +1,11 @@
|
|||
// Copyright (c) 2015, 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.
|
||||
|
||||
// Packages=.packages
|
||||
|
||||
// We expect this to not cause any errors. An empty packages file is valid,
|
||||
// you should only run into problems if you try to resolve a package import.
|
||||
library empty_packages_file_noimports_test;
|
||||
|
||||
main() {}
|
|
@ -0,0 +1,11 @@
|
|||
// Copyright (c) 2015, 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.
|
||||
|
||||
// Packages=.packages
|
||||
|
||||
library empty_packages_file_option_test;
|
||||
|
||||
import 'package:foo/foo.dart';
|
||||
|
||||
main() {}
|
7
tests/standalone/package/scenarios/invalid/foo/foo.dart
Normal file
7
tests/standalone/package/scenarios/invalid/foo/foo.dart
Normal file
|
@ -0,0 +1,7 @@
|
|||
// Copyright (c) 2015, 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.
|
||||
|
||||
library foo;
|
||||
|
||||
String foo = 'foo';
|
|
@ -0,0 +1,2 @@
|
|||
..:nonexistent/
|
||||
foo:foo/
|
|
@ -0,0 +1,15 @@
|
|||
// Copyright (c) 2015, 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.
|
||||
|
||||
// Packages=invalid_package_name.packages
|
||||
|
||||
library invalid_package_name_test;
|
||||
|
||||
import 'package:foo/foo.dart' as foo;
|
||||
|
||||
main() {
|
||||
if (foo.foo != 'foo') {
|
||||
throw new Exception('package "foo" was not resolved correctly');
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
þ:foo/
|
|
@ -0,0 +1,9 @@
|
|||
// Copyright (c) 2015, 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.
|
||||
|
||||
// Packages=invalid_utf8.packages
|
||||
|
||||
library invalid_utf8_test;
|
||||
|
||||
main() {}
|
|
@ -0,0 +1,9 @@
|
|||
// Copyright (c) 2015, 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.
|
||||
|
||||
// Packages=non_existent.packages
|
||||
|
||||
library non_existent_packages_file_test;
|
||||
|
||||
main() {}
|
|
@ -0,0 +1,3 @@
|
|||
foo:nonexistentdir/
|
||||
# This overrides the previous entry
|
||||
foo:foo/
|
|
@ -0,0 +1,11 @@
|
|||
// Copyright (c) 2015, 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.
|
||||
|
||||
// Packages=same_package_twice.packages
|
||||
|
||||
library same_package_twice_test;
|
||||
|
||||
import 'package:foo/foo.dart' as foo;
|
||||
|
||||
main() {}
|
|
@ -0,0 +1 @@
|
|||
foo:foo/
|
|
@ -0,0 +1,7 @@
|
|||
// Copyright (c) 2015, 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.
|
||||
|
||||
library foo;
|
||||
|
||||
String bar = 'hello';
|
|
@ -0,0 +1,9 @@
|
|||
// Copyright (c) 2015, 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.
|
||||
|
||||
// Packages=none
|
||||
|
||||
library packages_file_in_parent_noimports_test;
|
||||
|
||||
main() {}
|
|
@ -0,0 +1,15 @@
|
|||
// Copyright (c) 2015, 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.
|
||||
|
||||
// Packages=none
|
||||
|
||||
library packages_file_in_parent_test;
|
||||
|
||||
import 'package:foo/foo.dart' as foo;
|
||||
|
||||
main() {
|
||||
if (foo.bar != 'hello') {
|
||||
throw new Exception('package "foo" was not resolved correctly');
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
foo:foo/
|
|
@ -0,0 +1,7 @@
|
|||
// Copyright (c) 2015, 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.
|
||||
|
||||
library foo;
|
||||
|
||||
String bar = 'hello';
|
|
@ -0,0 +1,9 @@
|
|||
// Copyright (c) 2015, 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.
|
||||
|
||||
// Packages=none
|
||||
|
||||
library packages_file_only_noimports_test;
|
||||
|
||||
main() {}
|
|
@ -0,0 +1,15 @@
|
|||
// Copyright (c) 2015, 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.
|
||||
|
||||
// Packages=none
|
||||
|
||||
library packages_file_only_test;
|
||||
|
||||
import 'package:foo/foo.dart' as foo;
|
||||
|
||||
main() {
|
||||
if (foo.bar != 'hello') {
|
||||
throw new Exception('package "foo" was not resolved correctly');
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
// Copyright (c) 2015, 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.
|
||||
|
||||
library bar;
|
||||
|
||||
String bar = 'bar';
|
|
@ -0,0 +1,7 @@
|
|||
// Copyright (c) 2015, 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.
|
||||
|
||||
library baz;
|
||||
|
||||
String baz = 'baz';
|
|
@ -0,0 +1,20 @@
|
|||
|
||||
|
||||
|
||||
|
||||
foo:foo/
|
||||
|
||||
|
||||
bar:bar/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
baz:baz/
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
// Copyright (c) 2015, 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.
|
||||
|
||||
// Packages=empty_lines.packages
|
||||
|
||||
library empty_lines_test;
|
||||
|
||||
import 'package:foo/foo.dart' as foo;
|
||||
import 'package:bar/bar.dart' as bar;
|
||||
import 'package:baz/baz.dart' as baz;
|
||||
|
||||
main() {
|
||||
if (foo.foo != 'foo') {
|
||||
throw new Exception('package "foo" was not resolved correctly');
|
||||
}
|
||||
if (bar.bar != 'bar') {
|
||||
throw new Exception('package "bar" was not resolved correctly');
|
||||
}
|
||||
if (baz.baz != 'baz') {
|
||||
throw new Exception('package "baz" was not resolved correctly');
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
foo:
|
|
@ -0,0 +1,15 @@
|
|||
// Copyright (c) 2015, 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.
|
||||
|
||||
// Packages=empty_package_dir.packages
|
||||
|
||||
// In this test, we give a packages file that associates the package 'foo' with
|
||||
// the empty string. This causes both the VM and dart2js to resolve
|
||||
// 'package:foo' imports relative to the root directory. So the import statement
|
||||
// `import 'package:foo/foo.dart'` is equivalent to `import '/foo.dart'`.
|
||||
library empty_package_dir_test;
|
||||
|
||||
import 'package:foo/foo.dart';
|
||||
|
||||
main() {}
|
|
@ -0,0 +1,7 @@
|
|||
// Copyright (c) 2015, 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.
|
||||
|
||||
library foo;
|
||||
|
||||
String foo = 'foo';
|
|
@ -0,0 +1,3 @@
|
|||
foo:foo/
|
||||
bar:bar/
|
||||
baz:baz/
|
|
@ -0,0 +1,23 @@
|
|||
// Copyright (c) 2015, 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.
|
||||
|
||||
// Packages=mixed_line_ends.packages
|
||||
|
||||
library mixed_line_ends_test;
|
||||
|
||||
import 'package:foo/foo.dart' as foo;
|
||||
import 'package:bar/bar.dart' as bar;
|
||||
import 'package:baz/baz.dart' as baz;
|
||||
|
||||
main() {
|
||||
if (foo.foo != 'foo') {
|
||||
throw new Exception('package "foo" was not resolved correctly');
|
||||
}
|
||||
if (bar.bar != 'bar') {
|
||||
throw new Exception('package "bar" was not resolved correctly');
|
||||
}
|
||||
if (baz.baz != 'baz') {
|
||||
throw new Exception('package "baz" was not resolved correctly');
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
// Copyright (c) 2015, 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.
|
||||
|
||||
// Packages=sub/.packages
|
||||
|
||||
library packages_option_only_noimports_test;
|
||||
|
||||
main() {}
|
|
@ -0,0 +1,15 @@
|
|||
// Copyright (c) 2015, 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.
|
||||
|
||||
// Packages=sub/.packages
|
||||
|
||||
library packages_option_only_test;
|
||||
|
||||
import 'package:foo/foo.dart' as foo;
|
||||
|
||||
main() {
|
||||
if (foo.bar != 'hello') {
|
||||
throw new Exception('package "foo" was not resolved correctly');
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
foo:foo/
|
|
@ -0,0 +1,7 @@
|
|||
// Copyright (c) 2015, 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.
|
||||
|
||||
library foo;
|
||||
|
||||
String bar = 'hello';
|
14
tests/standalone/package/sibling_isolate.dart
Normal file
14
tests/standalone/package/sibling_isolate.dart
Normal file
|
@ -0,0 +1,14 @@
|
|||
// 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.
|
||||
|
||||
library sibling_isolate;
|
||||
|
||||
import 'package:shared.dart' as shared;
|
||||
import 'dart:isolate';
|
||||
|
||||
// This file is spawned from package_isolate_test.dart
|
||||
main(List<String> args, SendPort reply) {
|
||||
shared.output = 'isolate';
|
||||
reply.send(shared.output);
|
||||
}
|
15
tests/standalone/package/test_folder/folder_isolate.dart
Normal file
15
tests/standalone/package/test_folder/folder_isolate.dart
Normal file
|
@ -0,0 +1,15 @@
|
|||
// 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.
|
||||
|
||||
library folder_isolate;
|
||||
|
||||
// This is a package that's not available to the main isolate
|
||||
import 'package:folder_lib.dart' as isolate_package;
|
||||
import 'dart:isolate';
|
||||
|
||||
// This file is spawned from package_isolate_test.dart
|
||||
main(List<String> args, Sendport replyTo) {
|
||||
isolate_package.count = 1;
|
||||
replyTo.send('isolate');
|
||||
}
|
1011
tests/standalone/packages_file_test.dart
Normal file
1011
tests/standalone/packages_file_test.dart
Normal file
File diff suppressed because it is too large
Load diff
30
tests/standalone/pair_location_remapping_test.dart
Normal file
30
tests/standalone/pair_location_remapping_test.dart
Normal file
|
@ -0,0 +1,30 @@
|
|||
// Copyright (c) 2014, 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.
|
||||
// Test that pair locations are remaped in slow path environments.
|
||||
// VMOptions=--optimization_counter_threshold=10 --no-use-osr --no-background_compilation
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
class A {
|
||||
final f;
|
||||
A(this.f);
|
||||
}
|
||||
|
||||
foo(int i) {
|
||||
int j = 0x7fffffffffffffff + i;
|
||||
var c = new A(j); // allocation will be sunk
|
||||
var r = 0;
|
||||
for (var k = 0; k < 10; k++) {
|
||||
if ((j & (1 << k)) != 0) {
|
||||
r++;
|
||||
}
|
||||
}
|
||||
return c.f - r;
|
||||
}
|
||||
|
||||
main() {
|
||||
for (var i = 0; i < 1000; i++) {
|
||||
Expect.equals(0x7fffffffffffffff - 10, foo(0));
|
||||
}
|
||||
}
|
97
tests/standalone/pow_test.dart
Normal file
97
tests/standalone/pow_test.dart
Normal file
|
@ -0,0 +1,97 @@
|
|||
// Copyright (c) 2013, 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.
|
||||
//
|
||||
// Dart test program for testing math's pow.
|
||||
|
||||
library pow_test;
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
import 'dart:math';
|
||||
|
||||
var expectedResults = [
|
||||
1,
|
||||
2,
|
||||
4,
|
||||
8,
|
||||
16,
|
||||
32,
|
||||
64,
|
||||
128,
|
||||
256,
|
||||
512,
|
||||
1024,
|
||||
2048,
|
||||
4096,
|
||||
8192,
|
||||
16384,
|
||||
32768,
|
||||
65536,
|
||||
131072,
|
||||
262144,
|
||||
524288,
|
||||
1048576,
|
||||
2097152,
|
||||
4194304,
|
||||
8388608,
|
||||
16777216,
|
||||
33554432,
|
||||
67108864,
|
||||
134217728,
|
||||
268435456,
|
||||
536870912,
|
||||
1073741824,
|
||||
2147483648,
|
||||
4294967296,
|
||||
8589934592,
|
||||
17179869184,
|
||||
34359738368,
|
||||
68719476736,
|
||||
137438953472,
|
||||
274877906944,
|
||||
549755813888,
|
||||
1099511627776,
|
||||
2199023255552,
|
||||
4398046511104,
|
||||
8796093022208,
|
||||
17592186044416,
|
||||
35184372088832,
|
||||
70368744177664,
|
||||
140737488355328,
|
||||
281474976710656,
|
||||
562949953421312,
|
||||
1125899906842624,
|
||||
2251799813685248,
|
||||
4503599627370496,
|
||||
9007199254740992,
|
||||
18014398509481984,
|
||||
36028797018963968,
|
||||
72057594037927936,
|
||||
144115188075855872,
|
||||
288230376151711744,
|
||||
576460752303423488,
|
||||
1152921504606846976,
|
||||
2305843009213693952,
|
||||
4611686018427387904,
|
||||
];
|
||||
|
||||
void main() {
|
||||
int exp = 0;
|
||||
for (int val in expectedResults) {
|
||||
Expect.equals(val, pow(2, exp));
|
||||
Expect.equals(val.toDouble(), pow(2, exp.toDouble()));
|
||||
exp++;
|
||||
}
|
||||
|
||||
// Optimize it.
|
||||
for (int i = 0; i < 8888; i++) {
|
||||
pow(2, 3);
|
||||
pow(2.0, 3.0);
|
||||
}
|
||||
exp = 0;
|
||||
for (int val in expectedResults) {
|
||||
Expect.equals(val, pow(2, exp));
|
||||
Expect.equals(val.toDouble(), pow(2, exp.toDouble()));
|
||||
exp++;
|
||||
}
|
||||
}
|
327
tests/standalone/priority_queue_stress_test.dart
Normal file
327
tests/standalone/priority_queue_stress_test.dart
Normal file
|
@ -0,0 +1,327 @@
|
|||
// Copyright (c) 2014, 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.
|
||||
|
||||
library priority_queue;
|
||||
|
||||
import 'dart:collection';
|
||||
import 'dart:math';
|
||||
|
||||
/**
|
||||
* A priority used for the priority queue. Subclasses only need to implement
|
||||
* the compareTo function.
|
||||
*/
|
||||
abstract class Priority implements Comparable {
|
||||
/**
|
||||
* Return < 0 if other is bigger, >0 if other is smaller, 0 if they are equal.
|
||||
*/
|
||||
int compareTo(dynamic other);
|
||||
bool operator <(dynamic other) => compareTo(other) < 0;
|
||||
bool operator >(dynamic other) => compareTo(other) > 0;
|
||||
bool operator ==(dynamic other) => compareTo(other) == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Priority based on integers.
|
||||
*/
|
||||
class IntPriority extends Priority {
|
||||
int priority;
|
||||
IntPriority(int this.priority);
|
||||
|
||||
int compareTo(dynamic other) {
|
||||
return (priority - other.priority) as int;
|
||||
}
|
||||
|
||||
String toString() => "$priority";
|
||||
}
|
||||
|
||||
/**
|
||||
* An element of a priority queue. The type is used restriction based
|
||||
* querying of the queues.
|
||||
*/
|
||||
abstract class TypedElement<V> {
|
||||
bool typeEquals(var other);
|
||||
}
|
||||
|
||||
class StringTypedElement<V> extends TypedElement {
|
||||
String type;
|
||||
V value;
|
||||
StringTypedElement(String this.type, V this.value);
|
||||
bool typeEquals(dynamic otherType) => otherType == type;
|
||||
String toString() => "<Type: $type, Value: $value>";
|
||||
}
|
||||
|
||||
/**
|
||||
* A priority node in a priority queue. A priority node contains all of the
|
||||
* values for a given priority in a given queue. It is part of a linked
|
||||
* list of nodes, with prev and next pointers.
|
||||
*/
|
||||
class PriorityNode<N extends TypedElement, T extends Priority> {
|
||||
T priority;
|
||||
Queue<N> values;
|
||||
PriorityNode? prev;
|
||||
PriorityNode? next;
|
||||
PriorityNode(N initialNode, T this.priority) : values = new Queue<N>() {
|
||||
add(initialNode);
|
||||
}
|
||||
|
||||
void add(N n) => values.add(n);
|
||||
|
||||
bool remove(N n) => values.remove(n);
|
||||
|
||||
N removeFirst() => values.removeFirst();
|
||||
|
||||
bool get isEmpty => values.isEmpty;
|
||||
|
||||
N get first => values.first;
|
||||
|
||||
String toString() => "Priority: $priority $values";
|
||||
}
|
||||
|
||||
/**
|
||||
* A priority queue with a FIFO property for nodes with same priority.
|
||||
* The queue guarantees that nodes are returned in the same order they
|
||||
* are added for a given priority.
|
||||
* For type safety this queue is guarded by the elements being subclasses of
|
||||
* TypedElement - this is not strictly neccesary since we never actually
|
||||
* use the value or type of the nodes.
|
||||
*/
|
||||
class PriorityQueue<N extends TypedElement, P extends Priority> {
|
||||
PriorityNode<N, P>? head;
|
||||
int length = 0;
|
||||
|
||||
void add(N value, P priority) {
|
||||
length++;
|
||||
if (head == null) {
|
||||
head = new PriorityNode<N, P>(value, priority);
|
||||
return;
|
||||
}
|
||||
assert(head!.next == null);
|
||||
var node = head!;
|
||||
while (node.prev != null && node.priority > priority) {
|
||||
node = node.prev as PriorityNode<N, P>;
|
||||
}
|
||||
if (node.priority == priority) {
|
||||
node.add(value);
|
||||
} else if (node.priority < priority) {
|
||||
var newNode = new PriorityNode<N, P>(value, priority);
|
||||
newNode.next = node.next;
|
||||
if (node.next != null) node.next!.prev = newNode;
|
||||
newNode.prev = node;
|
||||
node.next = newNode;
|
||||
if (node == head) head = newNode;
|
||||
} else {
|
||||
var newNode = new PriorityNode<N, P>(value, priority);
|
||||
node.prev = newNode;
|
||||
newNode.next = node;
|
||||
}
|
||||
}
|
||||
|
||||
N get first => head!.first;
|
||||
|
||||
Priority get firstPriority => head!.priority;
|
||||
|
||||
bool get isEmpty => head == null;
|
||||
|
||||
N removeFirst() {
|
||||
if (isEmpty) throw "Can't get element from empty queue";
|
||||
var value = head!.removeFirst();
|
||||
if (head!.isEmpty) {
|
||||
if (head!.prev != null) {
|
||||
head!.prev!.next = null;
|
||||
}
|
||||
head = head!.prev as PriorityNode<N, P>?;
|
||||
}
|
||||
length--;
|
||||
assert(head == null || head!.next == null);
|
||||
return value;
|
||||
}
|
||||
|
||||
String toString() {
|
||||
if (head == null) return "Empty priority queue";
|
||||
var node = head!;
|
||||
var buffer = new StringBuffer();
|
||||
while (node.prev != null) {
|
||||
buffer.writeln(node);
|
||||
node = node.prev as PriorityNode<N, P>;
|
||||
}
|
||||
buffer.writeln(node);
|
||||
return buffer.toString();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements a specialized priority queue that efficiently allows getting
|
||||
* the highest priorized node that adheres to a set of restrictions.
|
||||
* Most notably it allows to get the highest priority node where the node's
|
||||
* type is not in an exclude list.
|
||||
* In addition, the queue has a number of properties:
|
||||
* The queue has fifo semantics for nodes with the same priority and type,
|
||||
* i.e., if nodes a and b are added to the queue with priority x and type z
|
||||
* then a is returned first iff a was added before b
|
||||
* For different types with the same priority no guarantees are given, but
|
||||
* the returned values try to be fair by returning from the biggest list of
|
||||
* tasks in case of priority clash. (This could be fixed by adding timestamps
|
||||
* to every node, that is _only_ used when collisions occur, not for
|
||||
* insertions)
|
||||
*/
|
||||
class RestrictViewPriorityQueue<N extends TypedElement, P extends Priority> {
|
||||
// We can't use the basic dart priority queue since it does not guarantee
|
||||
// FIFO for items with the same order. This is currently not uptimized for
|
||||
// different N, if many different N is expected here we should have a
|
||||
// priority queue instead of a list.
|
||||
List<PriorityQueue<N, P>> restrictedQueues = <PriorityQueue<N, P>>[];
|
||||
PriorityQueue<N, P> mainQueue = new PriorityQueue<N, P>();
|
||||
|
||||
void add(N value, P priority) {
|
||||
for (var queue in restrictedQueues) {
|
||||
if ((queue.first as StringTypedElement).value == value) {
|
||||
queue.add(value, priority);
|
||||
}
|
||||
}
|
||||
mainQueue.add(value, priority);
|
||||
}
|
||||
|
||||
bool get isEmpty => restrictedQueues.length + mainQueue.length == 0;
|
||||
|
||||
int get length =>
|
||||
restrictedQueues.fold<int>(0, (v, e) => v + e.length) + mainQueue.length;
|
||||
|
||||
PriorityQueue? getRestricted(List<N> restrictions) {
|
||||
var current = null;
|
||||
// Find highest restricted priority.
|
||||
for (var queue in restrictedQueues) {
|
||||
if (!restrictions.any((e) => queue.head!.first.typeEquals(e))) {
|
||||
if (current == null || queue.firstPriority > current.firstPriority) {
|
||||
current = queue;
|
||||
} else if (current.firstPriority == queue.firstPriority) {
|
||||
current = queue.length > current.length ? queue : current;
|
||||
}
|
||||
}
|
||||
}
|
||||
return current;
|
||||
}
|
||||
|
||||
N? get first {
|
||||
if (isEmpty) throw "Trying to remove node from empty queue";
|
||||
var candidate = getRestricted([]);
|
||||
if (candidate != null &&
|
||||
(mainQueue.isEmpty ||
|
||||
mainQueue.firstPriority < candidate.firstPriority)) {
|
||||
return candidate.first as N;
|
||||
}
|
||||
return mainQueue.isEmpty ? null : mainQueue.first;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the node that under the given set of restrictions.
|
||||
* If the queue is empty this function throws.
|
||||
* If the queue is not empty, but no node exists that adheres to the
|
||||
* restrictions we return null.
|
||||
*/
|
||||
N? removeFirst({List<N> restrictions: const []}) {
|
||||
if (isEmpty) throw "Trying to remove node from empty queue";
|
||||
var candidate = getRestricted(restrictions);
|
||||
|
||||
if (candidate != null &&
|
||||
(mainQueue.isEmpty ||
|
||||
mainQueue.firstPriority < candidate.firstPriority)) {
|
||||
var value = candidate.removeFirst();
|
||||
if (candidate.isEmpty) restrictedQueues.remove(candidate);
|
||||
return value as N;
|
||||
}
|
||||
while (!mainQueue.isEmpty) {
|
||||
var currentPriority = mainQueue.firstPriority;
|
||||
var current = mainQueue.removeFirst();
|
||||
if (!restrictions.any((e) => current.typeEquals(e))) {
|
||||
return current;
|
||||
} else {
|
||||
PriorityQueue<N, P>? restrictedQueue;
|
||||
for (var e in restrictedQueues) {
|
||||
if (current.typeEquals((e.first as StringTypedElement).type)) {
|
||||
restrictedQueue = e;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (restrictedQueue == null) {
|
||||
restrictedQueue = new PriorityQueue<N, P>();
|
||||
restrictedQueues.add(restrictedQueue);
|
||||
}
|
||||
restrictedQueue.add(current, currentPriority as P);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
String toString() {
|
||||
if (isEmpty) return "Empty queue";
|
||||
var buffer = new StringBuffer();
|
||||
if (!restrictedQueues.isEmpty) {
|
||||
buffer.writeln("Restricted queues");
|
||||
for (var queue in restrictedQueues) {
|
||||
buffer.writeln("$queue");
|
||||
}
|
||||
}
|
||||
buffer.writeln("Main queue:");
|
||||
buffer.writeln("$mainQueue");
|
||||
return buffer.toString();
|
||||
}
|
||||
}
|
||||
|
||||
/// TEMPORARY TESTING AND PERFORMANCE
|
||||
void main([args]) {
|
||||
stress(new RestrictViewPriorityQueue<StringTypedElement, IntPriority>());
|
||||
}
|
||||
|
||||
void stress(queue) {
|
||||
final int SIZE = 50000;
|
||||
Random random = new Random(29);
|
||||
|
||||
var priorities = [1, 2, 3, 16, 32, 42, 56, 57, 59, 90];
|
||||
var values = [
|
||||
new StringTypedElement('safari', 'foo'),
|
||||
new StringTypedElement('ie', 'bar'),
|
||||
new StringTypedElement('ff', 'foobar'),
|
||||
new StringTypedElement('dartium', 'barfoo'),
|
||||
new StringTypedElement('chrome', 'hest'),
|
||||
new StringTypedElement('drt', 'fisk')
|
||||
];
|
||||
|
||||
var restricted = [values[0], values[4]];
|
||||
|
||||
void addRandom() {
|
||||
queue.add(values[random.nextInt(values.length)],
|
||||
new IntPriority(priorities[random.nextInt(priorities.length)]));
|
||||
}
|
||||
|
||||
var stopwatch = new Stopwatch()..start();
|
||||
while (queue.length < SIZE) {
|
||||
addRandom();
|
||||
}
|
||||
|
||||
stopwatch.stop();
|
||||
print("Adding took: ${stopwatch.elapsedMilliseconds}");
|
||||
print("Queue length: ${queue.length}");
|
||||
|
||||
stopwatch = new Stopwatch()..start();
|
||||
while (queue.length > 0) {
|
||||
queue.removeFirst();
|
||||
}
|
||||
stopwatch.stop();
|
||||
print("Remowing took: ${stopwatch.elapsedMilliseconds}");
|
||||
print("Queue length: ${queue.length}");
|
||||
|
||||
print("Restricted add/remove");
|
||||
while (queue.length < SIZE) {
|
||||
addRandom();
|
||||
}
|
||||
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
if (random.nextDouble() < 0.5) {
|
||||
queue.removeFirst(restrictions: restricted);
|
||||
} else {
|
||||
queue.removeFirst();
|
||||
}
|
||||
addRandom();
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue