| Index: runtime/vm/dart_api_impl_test.cc
|
| ===================================================================
|
| --- runtime/vm/dart_api_impl_test.cc (revision 28227)
|
| +++ runtime/vm/dart_api_impl_test.cc (working copy)
|
| @@ -3844,12 +3844,12 @@
|
| EXPECT_EQ(7, int_value);
|
|
|
| // Allocate without a constructor.
|
| - result = Dart_Allocate(type);
|
| - EXPECT_VALID(result);
|
| + Dart_Handle obj = Dart_Allocate(type);
|
| + EXPECT_VALID(obj);
|
| instanceof = false;
|
| - EXPECT_VALID(Dart_ObjectIsType(result, type, &instanceof));
|
| + EXPECT_VALID(Dart_ObjectIsType(obj, type, &instanceof));
|
| EXPECT(instanceof);
|
| - foo = Dart_GetField(result, NewString("foo"));
|
| + foo = Dart_GetField(obj, NewString("foo"));
|
| EXPECT(Dart_IsNull(foo));
|
|
|
| // Invoke the unnamed constructor with an empty string.
|
| @@ -3863,6 +3863,19 @@
|
| EXPECT_VALID(Dart_IntegerToInt64(foo, &int_value));
|
| EXPECT_EQ(7, int_value);
|
|
|
| + // Allocate object and invoke the unnamed constructor with an empty string.
|
| + obj = Dart_Allocate(type);
|
| + EXPECT_VALID(obj);
|
| + instanceof = false;
|
| + EXPECT_VALID(Dart_ObjectIsType(obj, type, &instanceof));
|
| + EXPECT(instanceof);
|
| + result = Dart_Invoke(obj, NewString(""), 0, NULL);
|
| + EXPECT_VALID(result);
|
| + int_value = 0;
|
| + foo = Dart_GetField(obj, NewString("foo"));
|
| + EXPECT_VALID(Dart_IntegerToInt64(foo, &int_value));
|
| + EXPECT_EQ(7, int_value);
|
| +
|
| // Invoke a named constructor.
|
| result = Dart_New(type, NewString("named"), 1, args);
|
| EXPECT_VALID(result);
|
| @@ -3873,6 +3886,19 @@
|
| EXPECT_VALID(Dart_IntegerToInt64(foo, &int_value));
|
| EXPECT_EQ(11, int_value);
|
|
|
| + // Allocate object and invoke a named constructor.
|
| + obj = Dart_Allocate(type);
|
| + EXPECT_VALID(obj);
|
| + instanceof = false;
|
| + EXPECT_VALID(Dart_ObjectIsType(obj, type, &instanceof));
|
| + EXPECT(instanceof);
|
| + result = Dart_Invoke(obj, NewString("named"), 1, args);
|
| + EXPECT_VALID(result);
|
| + int_value = 0;
|
| + foo = Dart_GetField(obj, NewString("foo"));
|
| + EXPECT_VALID(Dart_IntegerToInt64(foo, &int_value));
|
| + EXPECT_EQ(11, int_value);
|
| +
|
| // Invoke a hidden named constructor.
|
| result = Dart_New(type, NewString("_hidden"), 1, args);
|
| EXPECT_VALID(result);
|
| @@ -3883,6 +3909,28 @@
|
| EXPECT_VALID(Dart_IntegerToInt64(foo, &int_value));
|
| EXPECT_EQ(-11, int_value);
|
|
|
| + // Allocate object and invoke a hidden named constructor.
|
| + obj = Dart_Allocate(type);
|
| + EXPECT_VALID(obj);
|
| + instanceof = false;
|
| + EXPECT_VALID(Dart_ObjectIsType(obj, type, &instanceof));
|
| + EXPECT(instanceof);
|
| + result = Dart_Invoke(obj, NewString("_hidden"), 1, args);
|
| + EXPECT_VALID(result);
|
| + int_value = 0;
|
| + foo = Dart_GetField(obj, NewString("foo"));
|
| + EXPECT_VALID(Dart_IntegerToInt64(foo, &int_value));
|
| + EXPECT_EQ(-11, int_value);
|
| +
|
| + // Allocate object and Invoke a constructor which throws an exception.
|
| + obj = Dart_Allocate(type);
|
| + EXPECT_VALID(obj);
|
| + instanceof = false;
|
| + EXPECT_VALID(Dart_ObjectIsType(obj, type, &instanceof));
|
| + EXPECT(instanceof);
|
| + result = Dart_Invoke(obj, NewString("exception"), 1, args);
|
| + EXPECT_ERROR(result, "ConstructorDeath");
|
| +
|
| // Invoke a factory constructor.
|
| result = Dart_New(type, NewString("multiply"), 1, args);
|
| EXPECT_VALID(result);
|
|
|