Files
sdk/tests/language/unsorted/expect_test.dart
T
Nicholas Shahan f860d84ad7 [test] Use Uris in place of Strings in test
Provides consistent behavior for identical and equals across all
backends. The test was failing on JavaScript backends because 
Strings that are equal are also identical.

Change-Id: I85929f37746d8f7e192410e3d2f6530ce05176c5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/343860
Reviewed-by: Nate Bosch <nbosch@google.com>
Auto-Submit: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Nate Bosch <nbosch@google.com>
2023-12-28 03:19:30 +00:00

78 lines
1.6 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.
// Testing the Expect class.
import "package:expect/expect.dart";
class ExpectTest {
static testEquals(a) {
try {
Expect.equals("AB", a, "within testEquals");
} on ExpectException catch (msg) {
print(msg);
return;
}
Expect.equals("AB", "${a}B");
throw "Expect.equals did not fail";
}
static testIsTrue(f) {
try {
Expect.isTrue(f);
} on ExpectException catch (msg) {
print(msg);
return;
}
Expect.isFalse(f);
throw "Expect.isTrue did not fail";
}
static testIsFalse(t) {
try {
Expect.isFalse(t);
} on ExpectException catch (msg) {
print(msg);
return;
}
Expect.isTrue(t);
throw "Expect.isFalse did not fail";
}
static testIdentical(uriA) {
var uriB = Uri.parse('$uriA');
try {
Expect.identical(uriA, uriB);
} on ExpectException catch (msg) {
print(msg);
return;
}
Expect.equals(uriA, uriB);
throw "Expect.identical did not fail";
}
static testFail() {
try {
Expect.fail("fail now");
} on ExpectException catch (msg) {
print(msg);
return;
}
throw "Expect.fail did not fail";
}
static void testMain() {
testEquals("A");
testIsTrue(false);
testIsTrue(1);
testIsFalse(true);
testIsFalse(0);
testIdentical(Uri.parse("A"));
testFail();
}
}
main() {
ExpectTest.testMain();
}