2e22f41612
https://codereview.chromium.org/1305183010/ - Reorder the priority of flags in the test harness when passed to the VM: default flags, file flags, command line flags - Ensure to not enable assertions when not being requested. Peter, any reason to not move the flags in to the configuration file? Why don't we actually have all of them in there? (not that I want to move them, I am just currious why we don't add them in there, it seems more logical to me) BUG= R=iposva@google.com, whesse@google.com Committed: https://github.com/dart-lang/sdk/commit/dd7767d95eda87054844e0b24ebd2ce9b04354bb Review URL: https://codereview.chromium.org//1330643003 .
78 lines
1.4 KiB
Dart
78 lines
1.4 KiB
Dart
// 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.
|
|
// VMOptions=--enable_asserts
|
|
//
|
|
// Dart test program testing assert statements.
|
|
|
|
import "package:expect/expect.dart";
|
|
|
|
class AssertionTest {
|
|
static testTrue() {
|
|
int i = 0;
|
|
try {
|
|
assert(true);
|
|
} on AssertionError catch (error) {
|
|
i = 1;
|
|
}
|
|
return i;
|
|
}
|
|
|
|
static testFalse() {
|
|
int i = 0;
|
|
try {
|
|
assert(false);
|
|
} on AssertionError catch (error) {
|
|
i = 1;
|
|
}
|
|
return i;
|
|
}
|
|
|
|
static unknown(var a) {
|
|
return (a) ? true : false;
|
|
}
|
|
|
|
static testUnknown() {
|
|
var x = unknown(false);
|
|
int i = 0;
|
|
try {
|
|
assert(x);
|
|
} on AssertionError catch (error) {
|
|
i = 1;
|
|
}
|
|
return i;
|
|
}
|
|
|
|
static testClosure() {
|
|
int i = 0;
|
|
try {
|
|
assert(() => false);
|
|
} on AssertionError catch (error) {
|
|
i = 1;
|
|
}
|
|
return i;
|
|
}
|
|
|
|
static testClosure2() {
|
|
int i = 0;
|
|
try {
|
|
var x = () => false;
|
|
assert(x);
|
|
} on AssertionError catch (error) {
|
|
i = 1;
|
|
}
|
|
return i;
|
|
}
|
|
|
|
static testMain() {
|
|
Expect.equals(0, testTrue());
|
|
Expect.equals(1, testFalse());
|
|
Expect.equals(1, testClosure());
|
|
Expect.equals(1, testClosure2());
|
|
}
|
|
}
|
|
|
|
main() {
|
|
AssertionTest.testMain();
|
|
}
|