dart-sdk/runtime/vm/assert_test.cc
Ryan Macnak 25548a912f [vm, reload] NoSuchMethodError after a static target goes missing or changes signature.
- Mostly restores the pre-kernel behavior, except that actual arguments are not passed to the NoSuchMethodError.
 - Instead of a vague error message, the call site whose target is missing is now part of the stack trace and the name/kind of the missing target is part of the exception message.
 - If the missing target is on a branch not taken, things properly succeed.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/37517
Bug: https://github.com/flutter/flutter/issues/122626
Change-Id: Ic3d5a386caa8d1627d8452a5601bc728ad519987
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/291055
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-03-30 19:27:17 +00:00

57 lines
1.1 KiB
C++

// 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.
#include "platform/assert.h"
#include "vm/unit_test.h"
VM_UNIT_TEST_CASE(Assert) {
ASSERT(true);
ASSERT(87 == 87);
ASSERT(42 != 87);
}
VM_UNIT_TEST_CASE(Expect) {
EXPECT(true);
EXPECT(87 == 87);
EXPECT(42 != 87);
EXPECT_EQ(0, 0);
EXPECT_EQ(42, 42);
EXPECT_EQ(true, true);
void* pointer = reinterpret_cast<void*>(42);
EXPECT_EQ(pointer, pointer);
EXPECT_STREQ("Hello", "Hello");
EXPECT_LT(1, 2);
EXPECT_LT(1, 1.5);
EXPECT_LT(-1.8, 3.14);
EXPECT_LE(1, 1);
EXPECT_LE(1, 2);
EXPECT_LE(0.5, 1);
EXPECT_GT(4, 1);
EXPECT_GT(2.3, 2.2229);
EXPECT_GE(4, 4);
EXPECT_GE(15.3, 15.3);
EXPECT_GE(5, 3);
EXPECT_FLOAT_EQ(15.43, 15.44, 0.01);
EXPECT_FLOAT_EQ(1.43, 1.43, 0.00);
}
VM_UNIT_TEST_CASE(Fail0) {
FAIL("This test fails");
}
VM_UNIT_TEST_CASE(Fail1) {
FAIL("This test fails with one argument: %d", 4);
}
VM_UNIT_TEST_CASE(Fail2) {
FAIL("This test fails with two arguments: %d, %d", -100, 42);
}