Files
sdk/tests/web/wasm/assertion_failure_message_test.dart
T
Jackson Gardner d0061b65fc [dart2wasm] Include file, line, and condition text in assertion's toString()
This fixes https://github.com/dart-lang/sdk/issues/55317

Change-Id: I2371423a9715059b8a4c4ede2ef567a4b6293287
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/360460
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Jackson Gardner <jacksongardner@google.com>
2024-04-03 14:14:08 +00:00

32 lines
1.1 KiB
Dart

// Copyright (c) 2024, 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.
// dart2wasmOptions=--enable-asserts
import 'package:expect/expect.dart';
void main() {
try {
assert(false, "failure message");
} on AssertionError catch (error) {
var message = error.toString();
Expect.contains('Assertion failed:', message);
Expect.contains('assertion_failure_message_test.dart:11:5', message);
Expect.contains('false', message);
Expect.contains('failure message', message);
}
// 失 All offsets and source code extractions should still be correct after
// non-UTF8 characters.
try {
assert(false, "after a non-UTF8 character");
} on AssertionError catch (error) {
var message = error.toString();
Expect.contains('Assertion failed:', message);
Expect.contains('assertion_failure_message_test.dart:23:5', message);
Expect.contains('false', message);
Expect.contains('after a non-UTF8 character', message);
}
}