Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(363)

Side by Side Diff: runtime/vm/dart_api_impl_test.cc

Issue 16968006: Add Dart_Allocate to the C++ API (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Allow Type objects as well Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« runtime/vm/dart_api_impl.cc ('K') | « runtime/vm/dart_api_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "bin/builtin.h" 5 #include "bin/builtin.h"
6 #include "include/dart_api.h" 6 #include "include/dart_api.h"
7 #include "include/dart_mirrors_api.h" 7 #include "include/dart_mirrors_api.h"
8 #include "include/dart_native_api.h" 8 #include "include/dart_native_api.h"
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 #include "platform/json.h" 10 #include "platform/json.h"
(...skipping 3901 matching lines...) Expand 10 before | Expand all | Expand 10 after
3912 Dart_Handle result = Dart_New(cls, Dart_Null(), 0, NULL); 3912 Dart_Handle result = Dart_New(cls, Dart_Null(), 0, NULL);
3913 EXPECT_VALID(result); 3913 EXPECT_VALID(result);
3914 bool instanceof = false; 3914 bool instanceof = false;
3915 EXPECT_VALID(Dart_ObjectIsType(result, cls, &instanceof)); 3915 EXPECT_VALID(Dart_ObjectIsType(result, cls, &instanceof));
3916 EXPECT(instanceof); 3916 EXPECT(instanceof);
3917 int64_t int_value = 0; 3917 int64_t int_value = 0;
3918 Dart_Handle foo = Dart_GetField(result, NewString("foo")); 3918 Dart_Handle foo = Dart_GetField(result, NewString("foo"));
3919 EXPECT_VALID(Dart_IntegerToInt64(foo, &int_value)); 3919 EXPECT_VALID(Dart_IntegerToInt64(foo, &int_value));
3920 EXPECT_EQ(7, int_value); 3920 EXPECT_EQ(7, int_value);
3921 3921
3922 // Allocate without a constructor.
3923 result = Dart_Allocate(cls);
siva 2013/06/19 15:36:24 I think you may run into conflicts with my CL. I h
3924 EXPECT_VALID(result);
3925 instanceof = false;
3926 EXPECT_VALID(Dart_ObjectIsType(result, cls, &instanceof));
3927 EXPECT(instanceof);
3928 foo = Dart_GetField(result, NewString("foo"));
3929 EXPECT(Dart_IsNull(foo));
3930
3922 // Invoke the unnamed constructor with an empty string. 3931 // Invoke the unnamed constructor with an empty string.
3923 result = Dart_New(cls, NewString(""), 0, NULL); 3932 result = Dart_New(cls, NewString(""), 0, NULL);
3924 EXPECT_VALID(result); 3933 EXPECT_VALID(result);
3925 instanceof = false; 3934 instanceof = false;
3926 EXPECT_VALID(Dart_ObjectIsType(result, cls, &instanceof)); 3935 EXPECT_VALID(Dart_ObjectIsType(result, cls, &instanceof));
3927 EXPECT(instanceof); 3936 EXPECT(instanceof);
3928 int_value = 0; 3937 int_value = 0;
3929 foo = Dart_GetField(result, NewString("foo")); 3938 foo = Dart_GetField(result, NewString("foo"));
3930 EXPECT_VALID(Dart_IntegerToInt64(foo, &int_value)); 3939 EXPECT_VALID(Dart_IntegerToInt64(foo, &int_value));
3931 EXPECT_EQ(7, int_value); 3940 EXPECT_EQ(7, int_value);
(...skipping 4167 matching lines...) Expand 10 before | Expand all | Expand 10 after
8099 NewString("main"), 8108 NewString("main"),
8100 0, 8109 0,
8101 NULL); 8110 NULL);
8102 int64_t value = 0; 8111 int64_t value = 0;
8103 result = Dart_IntegerToInt64(result, &value); 8112 result = Dart_IntegerToInt64(result, &value);
8104 EXPECT_VALID(result); 8113 EXPECT_VALID(result);
8105 EXPECT_EQ(8, value); 8114 EXPECT_EQ(8, value);
8106 } 8115 }
8107 8116
8108 } // namespace dart 8117 } // namespace dart
OLDNEW
« runtime/vm/dart_api_impl.cc ('K') | « runtime/vm/dart_api_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698