Update tests to pass in web/production mode.

Change-Id: Ibea6022fcdd0eff53c6be9a5f7c0eeb0fbf20635
CoreLibraryReviewExempt: Updating tests to pass for web production backend.
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/343822
Reviewed-by: Mayank Patke <fishythefish@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
This commit is contained in:
Nate Biggs 2024-01-08 17:21:29 +00:00 committed by Commit Queue
parent 3c42222b7e
commit 5229eabddf
3 changed files with 16 additions and 12 deletions

View file

@ -85,6 +85,7 @@ class CoreRuntimeTypesTest {
}
static testOperatorErrors() {
if (dart2jsProductionMode) return; // Argument checks not performed.
var objs = [
1,
'2',

View file

@ -6,10 +6,10 @@ import "package:expect/expect.dart";
import "dart:math" show pow, log;
void main() {
const String oneByteWhiteSpace = "\x09\x0a\x0b\x0c\x0d\x20"
"\x85" //# 01: ok
"\xa0";
const String whiteSpace = "$oneByteWhiteSpace\u1680"
final String oneByteWhiteSpace = webNumbers
? "\x09\x0a\x0b\x0c\x0d\x20\xa0"
: "\x09\x0a\x0b\x0c\x0d\x20\x85\xa0";
final String whiteSpace = "$oneByteWhiteSpace\u1680"
"\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a"
"\u2028\u2029\u202f\u205f\u3000\ufeff";
@ -92,8 +92,8 @@ void main() {
Expect.equals(1, int.parse("+1", radix: 2));
void testFails(String source, int radix) {
Expect.throwsFormatException(
() => int.parse(source, radix: radix), "$source/$radix");
Expect.throwsFormatException(
() => int.parse(source, radix: radix), "$source/$radix");
Expect.equals(-999, int.tryParse(source, radix: radix) ?? -999);
}
@ -113,8 +113,7 @@ void main() {
testBadArguments(String source, int radix) {
// If the types match, it should be an ArgumentError of some sort.
Expect.throwsArgumentError(
() => int.parse(source, radix: radix));
Expect.throwsArgumentError(() => int.parse(source, radix: radix));
}
testBadArguments("0", -1);

View file

@ -25,10 +25,14 @@ void testModifiableList(l1) {
// Index must be integer and in range.
Expect.throwsRangeError(() => l1.removeAt(-1), "negative");
Expect.throwsRangeError(() => l1.removeAt(5), "too large");
Expect.throws(() => l1.removeAt(null),
// With sound null safety a TypeError is thrown.
// Without sound null safety an ArgumentError is thrown.
(e) => e is TypeError || e is ArgumentError, "is null");
if (!dart2jsProductionMode) {
Expect.throws(
() => l1.removeAt(null),
// With sound null safety a TypeError is thrown.
// Without sound null safety an ArgumentError is thrown.
(e) => e is TypeError || e is ArgumentError,
"is null");
}
Expect.equals(2, l1.removeAt(2), "l1-remove2");
Expect.equals(1, l1[1], "l1-1[1]");