| Index: runtime/vm/dart_api_impl_test.cc
|
| ===================================================================
|
| --- runtime/vm/dart_api_impl_test.cc (revision 1230)
|
| +++ runtime/vm/dart_api_impl_test.cc (working copy)
|
| @@ -30,6 +30,58 @@
|
| }
|
|
|
|
|
| +UNIT_TEST_CASE(Equals) {
|
| + Dart_CreateIsolate(NULL, NULL);
|
| + Dart_EnterScope(); // Enter a Dart API scope for the unit test.
|
| +
|
| + bool equal = false;
|
| + Dart_Handle five = Dart_NewString("5");
|
| + Dart_Handle five_again = Dart_NewString("5");
|
| + Dart_Handle seven = Dart_NewString("7");
|
| +
|
| + // Identical objects.
|
| + EXPECT_VALID(Dart_Equals(five, five, &equal));
|
| + EXPECT(equal);
|
| +
|
| + // Equal objects.
|
| + EXPECT_VALID(Dart_Equals(five, five_again, &equal));
|
| + EXPECT(equal);
|
| +
|
| + // Different objects.
|
| + EXPECT_VALID(Dart_Equals(five, seven, &equal));
|
| + EXPECT(!equal);
|
| +
|
| + Dart_ExitScope(); // Exit the Dart API scope.
|
| + Dart_ShutdownIsolate();
|
| +}
|
| +
|
| +
|
| +UNIT_TEST_CASE(TripleEquals) {
|
| + Dart_CreateIsolate(NULL, NULL);
|
| + Dart_EnterScope(); // Enter a Dart API scope for the unit test.
|
| +
|
| + bool identical = false;
|
| + Dart_Handle five = Dart_NewString("5");
|
| + Dart_Handle five_again = Dart_NewString("5");
|
| + Dart_Handle seven = Dart_NewString("7");
|
| +
|
| + // Identical objects.
|
| + EXPECT_VALID(Dart_TripleEquals(five, five, &identical));
|
| + EXPECT(identical);
|
| +
|
| + // Equal objects.
|
| + EXPECT_VALID(Dart_TripleEquals(five, five_again, &identical));
|
| + EXPECT(!identical);
|
| +
|
| + // Different objects.
|
| + EXPECT_VALID(Dart_TripleEquals(five, seven, &identical));
|
| + EXPECT(!identical);
|
| +
|
| + Dart_ExitScope(); // Exit the Dart API scope.
|
| + Dart_ShutdownIsolate();
|
| +}
|
| +
|
| +
|
| UNIT_TEST_CASE(BooleanValues) {
|
| Dart_CreateIsolate(NULL, NULL);
|
| Dart_EnterScope(); // Enter a Dart API scope for the unit test.
|
| @@ -1589,7 +1641,7 @@
|
| // Now check instanceOfTestObj reported as an instance of
|
| // InstanceOfTest class.
|
| bool is_instance = false;
|
| - result = Dart_IsInstanceOf(instanceOfTestObj, cls, &is_instance);
|
| + result = Dart_IsType(instanceOfTestObj, cls, &is_instance);
|
| EXPECT_VALID(result);
|
| EXPECT(is_instance);
|
|
|
| @@ -1598,21 +1650,21 @@
|
| EXPECT_VALID(otherClass);
|
| EXPECT(!Dart_ExceptionOccurred(otherClass));
|
|
|
| - result = Dart_IsInstanceOf(instanceOfTestObj, otherClass, &is_instance);
|
| + result = Dart_IsType(instanceOfTestObj, otherClass, &is_instance);
|
| EXPECT_VALID(result);
|
| EXPECT(!is_instance);
|
|
|
| // Check that primitives are not instances of InstanceOfTest class.
|
| - result = Dart_IsInstanceOf(Dart_NewString("a string"), otherClass,
|
| + result = Dart_IsType(Dart_NewString("a string"), otherClass,
|
| &is_instance);
|
| EXPECT_VALID(result);
|
| EXPECT(!is_instance);
|
|
|
| - result = Dart_IsInstanceOf(Dart_NewInteger(42), otherClass, &is_instance);
|
| + result = Dart_IsType(Dart_NewInteger(42), otherClass, &is_instance);
|
| EXPECT_VALID(result);
|
| EXPECT(!is_instance);
|
|
|
| - result = Dart_IsInstanceOf(Dart_NewBoolean(true), otherClass, &is_instance);
|
| + result = Dart_IsType(Dart_NewBoolean(true), otherClass, &is_instance);
|
| EXPECT_VALID(result);
|
| EXPECT(!is_instance);
|
|
|
| @@ -1625,12 +1677,12 @@
|
| EXPECT_VALID(null);
|
| EXPECT(!Dart_ExceptionOccurred(null));
|
|
|
| - result = Dart_IsInstanceOf(null, otherClass, &is_instance);
|
| + result = Dart_IsType(null, otherClass, &is_instance);
|
| EXPECT_VALID(result);
|
| EXPECT(!is_instance);
|
|
|
| // Check that error is returned if null is passed as a class argument.
|
| - result = Dart_IsInstanceOf(null, null, &is_instance);
|
| + result = Dart_IsType(null, null, &is_instance);
|
| EXPECT(!Dart_IsValid(result));
|
|
|
| Dart_ExitScope(); // Exit the Dart API scope.
|
|
|