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

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

Issue 9264058: Debugger API: get local variables of an activation frame (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 8 years, 10 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
« no previous file with comments | « runtime/vm/debugger_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 "include/dart_debugger_api.h" 5 #include "include/dart_debugger_api.h"
6 #include "platform/assert.h" 6 #include "platform/assert.h"
7 #include "vm/dart_api_impl.h" 7 #include "vm/dart_api_impl.h"
8 #include "vm/unit_test.h" 8 #include "vm/unit_test.h"
9 9
10 namespace dart { 10 namespace dart {
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 EXPECT(!Dart_IsError(retval)); 153 EXPECT(!Dart_IsError(retval));
154 EXPECT(breakpoint_hit_counter == 2); 154 EXPECT(breakpoint_hit_counter == 2);
155 } 155 }
156 156
157 157
158 TEST_CASE(Debug_InspectObject) { 158 TEST_CASE(Debug_InspectObject) {
159 const char* kScriptChars = 159 const char* kScriptChars =
160 " class A { \n" 160 " class A { \n"
161 " var a_field = 'a'; \n" 161 " var a_field = 'a'; \n"
162 " static var bla = 'yada yada yada';\n" 162 " static var bla = 'yada yada yada';\n"
163 " static var error = unresolvedName(); \n"
163 " var d = 42.1; \n" 164 " var d = 42.1; \n"
164 " } \n" 165 " } \n"
165 " class B extends A { \n" 166 " class B extends A { \n"
166 " var oneDay = const Duration(hours: 24); \n" 167 " var oneDay = const Duration(hours: 24); \n"
167 " static var bla = 'blah blah'; \n" 168 " static var bla = 'blah blah'; \n"
168 " } \n" 169 " } \n"
169 " get_b() { return new B(); } \n" 170 " get_b() { return new B(); } \n"
170 " get_int() { return 666; } \n"; 171 " get_int() { return 666; } \n";
171 172
172 // Number of instance fields in an object of class B. 173 // Number of instance fields in an object of class B.
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 EXPECT_STREQ("bla", name); 237 EXPECT_STREQ("bla", name);
237 Dart_Handle value_handle = Dart_ListGetAt(fields, 1); 238 Dart_Handle value_handle = Dart_ListGetAt(fields, 1);
238 EXPECT_NOT_ERROR(value_handle); 239 EXPECT_NOT_ERROR(value_handle);
239 value_handle = Dart_ToString(value_handle); 240 value_handle = Dart_ToString(value_handle);
240 EXPECT_NOT_ERROR(value_handle); 241 EXPECT_NOT_ERROR(value_handle);
241 EXPECT(Dart_IsString(value_handle)); 242 EXPECT(Dart_IsString(value_handle));
242 char const* value; 243 char const* value;
243 Dart_StringToCString(value_handle, &value); 244 Dart_StringToCString(value_handle, &value);
244 EXPECT_STREQ("blah blah", value); 245 EXPECT_STREQ("blah blah", value);
245 246
246 // Check static field of B's superclass (one field named 'bla') 247 // Check static field of B's superclass.
247 Dart_Handle class_A = Dart_GetSuperclass(class_B); 248 Dart_Handle class_A = Dart_GetSuperclass(class_B);
248 EXPECT_NOT_ERROR(class_A); 249 EXPECT_NOT_ERROR(class_A);
249 EXPECT(!Dart_IsNull(class_A)); 250 EXPECT(!Dart_IsNull(class_A));
250 fields = Dart_GetStaticFields(class_A); 251 fields = Dart_GetStaticFields(class_A);
251 EXPECT_NOT_ERROR(fields); 252 EXPECT_NOT_ERROR(fields);
252 EXPECT(Dart_IsList(fields)); 253 EXPECT(Dart_IsList(fields));
253 list_length = 0; 254 list_length = 0;
254 retval = Dart_ListLength(fields, &list_length); 255 retval = Dart_ListLength(fields, &list_length);
255 EXPECT_NOT_ERROR(retval); 256 EXPECT_NOT_ERROR(retval);
256 EXPECT_EQ(2, list_length); 257 EXPECT_EQ(4, list_length);
258 // Static field "bla" should have value "yada yada yada".
257 name_handle = Dart_ListGetAt(fields, 0); 259 name_handle = Dart_ListGetAt(fields, 0);
258 EXPECT_NOT_ERROR(name_handle); 260 EXPECT_NOT_ERROR(name_handle);
259 EXPECT(Dart_IsString(name_handle)); 261 EXPECT(Dart_IsString(name_handle));
260 Dart_StringToCString(name_handle, &name); 262 Dart_StringToCString(name_handle, &name);
261 EXPECT_STREQ("bla", name); 263 EXPECT_STREQ("bla", name);
262 value_handle = Dart_ListGetAt(fields, 1); 264 value_handle = Dart_ListGetAt(fields, 1);
263 EXPECT_NOT_ERROR(value_handle); 265 EXPECT_NOT_ERROR(value_handle);
264 value_handle = Dart_ToString(value_handle); 266 value_handle = Dart_ToString(value_handle);
265 EXPECT_NOT_ERROR(value_handle); 267 EXPECT_NOT_ERROR(value_handle);
266 EXPECT(Dart_IsString(value_handle)); 268 EXPECT(Dart_IsString(value_handle));
267 Dart_StringToCString(value_handle, &value); 269 Dart_StringToCString(value_handle, &value);
268 EXPECT_STREQ("yada yada yada", value); 270 EXPECT_STREQ("yada yada yada", value);
271 // The static field "error" should result in a compile error.
272 name_handle = Dart_ListGetAt(fields, 2);
273 EXPECT_NOT_ERROR(name_handle);
274 EXPECT(Dart_IsString(name_handle));
275 Dart_StringToCString(name_handle, &name);
276 EXPECT_STREQ("error", name);
277 value_handle = Dart_ListGetAt(fields, 3);
278 EXPECT(Dart_IsError(value_handle));
269 } 279 }
270 280
271 281
272 TEST_CASE(Debug_LookupSourceLine) { 282 TEST_CASE(Debug_LookupSourceLine) {
273 const char* kScriptChars = 283 const char* kScriptChars =
274 /*1*/ "class A {\n" 284 /*1*/ "class A {\n"
275 /*2*/ " static void foo() {\n" 285 /*2*/ " static void foo() {\n"
276 /*3*/ " moo('good news');\n" 286 /*3*/ " moo('good news');\n"
277 /*4*/ " }\n" 287 /*4*/ " }\n"
278 /*5*/ "}\n" 288 /*5*/ "}\n"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 EXPECT(Dart_IsString(source)); 348 EXPECT(Dart_IsString(source));
339 char const* source_chars; 349 char const* source_chars;
340 Dart_StringToCString(source, &source_chars); 350 Dart_StringToCString(source, &source_chars);
341 printf("\n=== source: ===\n%s", source_chars); 351 printf("\n=== source: ===\n%s", source_chars);
342 EXPECT_STREQ(kScriptChars, source_chars); 352 EXPECT_STREQ(kScriptChars, source_chars);
343 } 353 }
344 354
345 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). 355 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64).
346 356
347 } // namespace dart 357 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/debugger_api_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698