| OLD | NEW |
| 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 "platform/globals.h" | 5 #include "platform/globals.h" |
| 6 | 6 |
| 7 #include "vm/assembler.h" | 7 #include "vm/assembler.h" |
| 8 #include "vm/class_finalizer.h" | 8 #include "vm/class_finalizer.h" |
| 9 #include "vm/dart_api_impl.h" | 9 #include "vm/dart_api_impl.h" |
| 10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
| (...skipping 4211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4222 ObjectAccumulator acc(&objects); | 4222 ObjectAccumulator acc(&objects); |
| 4223 heap->IterateObjects(&acc); | 4223 heap->IterateObjects(&acc); |
| 4224 for (intptr_t i = 0; i < objects.length(); ++i) { | 4224 for (intptr_t i = 0; i < objects.length(); ++i) { |
| 4225 JSONStream js; | 4225 JSONStream js; |
| 4226 objects[i]->PrintJSON(&js, false); | 4226 objects[i]->PrintJSON(&js, false); |
| 4227 EXPECT_SUBSTRING("\"type\":", js.ToCString()); | 4227 EXPECT_SUBSTRING("\"type\":", js.ToCString()); |
| 4228 } | 4228 } |
| 4229 } | 4229 } |
| 4230 | 4230 |
| 4231 | 4231 |
| 4232 // Elide a substring which starts with some prefix and ends with a ". | |
| 4233 // | |
| 4234 // This is used to remove non-deterministic or fragile substrings from | |
| 4235 // JSON output. | |
| 4236 // | |
| 4237 // For example: | |
| 4238 // | |
| 4239 // prefix = "classes" | |
| 4240 // in = "\"id\":\"classes/46\"" | |
| 4241 // | |
| 4242 // Yields: | |
| 4243 // | |
| 4244 // out = "\"id\":\"\"" | |
| 4245 // | |
| 4246 static void elideSubstring(const char* prefix, const char* in, char* out) { | |
| 4247 const char* pos = strstr(in, prefix); | |
| 4248 while (pos != NULL) { | |
| 4249 // Copy up to pos into the output buffer. | |
| 4250 while (in < pos) { | |
| 4251 *out++ = *in++; | |
| 4252 } | |
| 4253 | |
| 4254 // Skip to the close quote. | |
| 4255 in += strcspn(in, "\""); | |
| 4256 pos = strstr(in, prefix); | |
| 4257 } | |
| 4258 // Copy the remainder of in to out. | |
| 4259 while (*in != '\0') { | |
| 4260 *out++ = *in++; | |
| 4261 } | |
| 4262 *out = '\0'; | |
| 4263 } | |
| 4264 | |
| 4265 | |
| 4266 TEST_CASE(PrintJSONPrimitives) { | 4232 TEST_CASE(PrintJSONPrimitives) { |
| 4267 char buffer[1024]; | 4233 char buffer[1024]; |
| 4268 Isolate* isolate = Isolate::Current(); | 4234 Isolate* isolate = Isolate::Current(); |
| 4269 | 4235 |
| 4270 // Class reference | 4236 // Class reference |
| 4271 { | 4237 { |
| 4272 JSONStream js; | 4238 JSONStream js; |
| 4273 Class& cls = Class::Handle(isolate->object_store()->bool_class()); | 4239 Class& cls = Class::Handle(isolate->object_store()->bool_class()); |
| 4274 cls.PrintJSON(&js, true); | 4240 cls.PrintJSON(&js, true); |
| 4275 elideSubstring("classes", js.ToCString(), buffer); | 4241 ElideJSONSubstring("classes", js.ToCString(), buffer); |
| 4276 EXPECT_STREQ( | 4242 EXPECT_STREQ( |
| 4277 "{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\",\"name\":\"bool\"}", | 4243 "{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\",\"name\":\"bool\"}", |
| 4278 buffer); | 4244 buffer); |
| 4279 } | 4245 } |
| 4280 // Function reference | 4246 // Function reference |
| 4281 { | 4247 { |
| 4282 JSONStream js; | 4248 JSONStream js; |
| 4283 Class& cls = Class::Handle(isolate->object_store()->bool_class()); | 4249 Class& cls = Class::Handle(isolate->object_store()->bool_class()); |
| 4284 const String& func_name = String::Handle(String::New("toString")); | 4250 const String& func_name = String::Handle(String::New("toString")); |
| 4285 Function& func = Function::Handle(cls.LookupFunction(func_name)); | 4251 Function& func = Function::Handle(cls.LookupFunction(func_name)); |
| 4286 ASSERT(!func.IsNull()); | 4252 ASSERT(!func.IsNull()); |
| 4287 func.PrintJSON(&js, true); | 4253 func.PrintJSON(&js, true); |
| 4288 elideSubstring("classes", js.ToCString(), buffer); | 4254 ElideJSONSubstring("classes", js.ToCString(), buffer); |
| 4289 EXPECT_STREQ( | 4255 EXPECT_STREQ( |
| 4290 "{\"type\":\"@Function\",\"fixedId\":true," | 4256 "{\"type\":\"@Function\",\"fixedId\":true," |
| 4291 "\"id\":\"\",\"name\":\"toString\"," | 4257 "\"id\":\"\",\"name\":\"toString\"," |
| 4292 "\"owner\":{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\"," | 4258 "\"owner\":{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\"," |
| 4293 "\"name\":\"bool\"}," | 4259 "\"name\":\"bool\"}," |
| 4294 "\"_kind\":\"RegularFunction\"," | 4260 "\"_kind\":\"RegularFunction\"," |
| 4295 "\"static\":false,\"const\":false}", | 4261 "\"static\":false,\"const\":false}", |
| 4296 buffer); | 4262 buffer); |
| 4297 } | 4263 } |
| 4298 // Library reference | 4264 // Library reference |
| 4299 { | 4265 { |
| 4300 JSONStream js; | 4266 JSONStream js; |
| 4301 Library& lib = Library::Handle(isolate->object_store()->core_library()); | 4267 Library& lib = Library::Handle(isolate->object_store()->core_library()); |
| 4302 lib.PrintJSON(&js, true); | 4268 lib.PrintJSON(&js, true); |
| 4303 elideSubstring("libraries", js.ToCString(), buffer); | 4269 ElideJSONSubstring("libraries", js.ToCString(), buffer); |
| 4304 EXPECT_STREQ( | 4270 EXPECT_STREQ( |
| 4305 "{\"type\":\"@Library\",\"fixedId\":true,\"id\":\"\"," | 4271 "{\"type\":\"@Library\",\"fixedId\":true,\"id\":\"\"," |
| 4306 "\"name\":\"dart.core\",\"uri\":\"dart:core\"}", | 4272 "\"name\":\"dart.core\",\"uri\":\"dart:core\"}", |
| 4307 buffer); | 4273 buffer); |
| 4308 } | 4274 } |
| 4309 // Bool reference | 4275 // Bool reference |
| 4310 { | 4276 { |
| 4311 JSONStream js; | 4277 JSONStream js; |
| 4312 Bool::True().PrintJSON(&js, true); | 4278 Bool::True().PrintJSON(&js, true); |
| 4313 elideSubstring("classes", js.ToCString(), buffer); | 4279 ElideJSONSubstring("classes", js.ToCString(), buffer); |
| 4314 EXPECT_STREQ( | 4280 EXPECT_STREQ( |
| 4315 "{\"type\":\"@Instance\"," | 4281 "{\"type\":\"@Instance\"," |
| 4316 "\"_vmType\":\"Bool\"," | 4282 "\"_vmType\":\"Bool\"," |
| 4317 "\"class\":{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\"," | 4283 "\"class\":{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\"," |
| 4318 "\"name\":\"bool\"}," | 4284 "\"name\":\"bool\"}," |
| 4319 "\"kind\":\"Bool\"," | 4285 "\"kind\":\"Bool\"," |
| 4320 "\"fixedId\":true," | 4286 "\"fixedId\":true," |
| 4321 "\"id\":\"objects\\/bool-true\",\"valueAsString\":\"true\"}", | 4287 "\"id\":\"objects\\/bool-true\",\"valueAsString\":\"true\"}", |
| 4322 buffer); | 4288 buffer); |
| 4323 } | 4289 } |
| 4324 // Smi reference | 4290 // Smi reference |
| 4325 { | 4291 { |
| 4326 JSONStream js; | 4292 JSONStream js; |
| 4327 const Integer& smi = Integer::Handle(Integer::New(7)); | 4293 const Integer& smi = Integer::Handle(Integer::New(7)); |
| 4328 smi.PrintJSON(&js, true); | 4294 smi.PrintJSON(&js, true); |
| 4329 elideSubstring("classes", js.ToCString(), buffer); | 4295 ElideJSONSubstring("classes", js.ToCString(), buffer); |
| 4330 elideSubstring("_Smi@", buffer, buffer); | 4296 ElideJSONSubstring("_Smi@", buffer, buffer); |
| 4331 EXPECT_STREQ( | 4297 EXPECT_STREQ( |
| 4332 "{\"type\":\"@Instance\"," | 4298 "{\"type\":\"@Instance\"," |
| 4333 "\"_vmType\":\"Smi\"," | 4299 "\"_vmType\":\"Smi\"," |
| 4334 "\"class\":{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\"," | 4300 "\"class\":{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\"," |
| 4335 "\"name\":\"_Smi\"," | 4301 "\"name\":\"_Smi\"," |
| 4336 "\"_vmName\":\"\"}," | 4302 "\"_vmName\":\"\"}," |
| 4337 "\"kind\":\"Int\"," | 4303 "\"kind\":\"Int\"," |
| 4338 "\"fixedId\":true," | 4304 "\"fixedId\":true," |
| 4339 "\"id\":\"objects\\/int-7\",\"valueAsString\":\"7\"}", | 4305 "\"id\":\"objects\\/int-7\",\"valueAsString\":\"7\"}", |
| 4340 buffer); | 4306 buffer); |
| 4341 } | 4307 } |
| 4342 // Mint reference | 4308 // Mint reference |
| 4343 { | 4309 { |
| 4344 JSONStream js; | 4310 JSONStream js; |
| 4345 const Integer& smi = Integer::Handle(Integer::New(Mint::kMinValue)); | 4311 const Integer& smi = Integer::Handle(Integer::New(Mint::kMinValue)); |
| 4346 smi.PrintJSON(&js, true); | 4312 smi.PrintJSON(&js, true); |
| 4347 elideSubstring("classes", js.ToCString(), buffer); | 4313 ElideJSONSubstring("classes", js.ToCString(), buffer); |
| 4348 elideSubstring("objects", buffer, buffer); | 4314 ElideJSONSubstring("objects", buffer, buffer); |
| 4349 elideSubstring("_Mint@", buffer, buffer); | 4315 ElideJSONSubstring("_Mint@", buffer, buffer); |
| 4350 EXPECT_STREQ( | 4316 EXPECT_STREQ( |
| 4351 "{\"type\":\"@Instance\"," | 4317 "{\"type\":\"@Instance\"," |
| 4352 "\"_vmType\":\"Mint\"," | 4318 "\"_vmType\":\"Mint\"," |
| 4353 "\"class\":{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\"," | 4319 "\"class\":{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\"," |
| 4354 "\"name\":\"_Mint\",\"_vmName\":\"\"}," | 4320 "\"name\":\"_Mint\",\"_vmName\":\"\"}," |
| 4355 "\"kind\":\"Int\"," | 4321 "\"kind\":\"Int\"," |
| 4356 "\"id\":\"\",\"valueAsString\":\"-9223372036854775808\"}", | 4322 "\"id\":\"\",\"valueAsString\":\"-9223372036854775808\"}", |
| 4357 buffer); | 4323 buffer); |
| 4358 } | 4324 } |
| 4359 // Bigint reference | 4325 // Bigint reference |
| 4360 { | 4326 { |
| 4361 JSONStream js; | 4327 JSONStream js; |
| 4362 const String& bigint_str = | 4328 const String& bigint_str = |
| 4363 String::Handle(String::New("44444444444444444444444444444444")); | 4329 String::Handle(String::New("44444444444444444444444444444444")); |
| 4364 const Integer& bigint = Integer::Handle(Integer::New(bigint_str)); | 4330 const Integer& bigint = Integer::Handle(Integer::New(bigint_str)); |
| 4365 bigint.PrintJSON(&js, true); | 4331 bigint.PrintJSON(&js, true); |
| 4366 elideSubstring("classes", js.ToCString(), buffer); | 4332 ElideJSONSubstring("classes", js.ToCString(), buffer); |
| 4367 elideSubstring("objects", buffer, buffer); | 4333 ElideJSONSubstring("objects", buffer, buffer); |
| 4368 elideSubstring("_Bigint@", buffer, buffer); | 4334 ElideJSONSubstring("_Bigint@", buffer, buffer); |
| 4369 EXPECT_STREQ( | 4335 EXPECT_STREQ( |
| 4370 "{\"type\":\"@Instance\"," | 4336 "{\"type\":\"@Instance\"," |
| 4371 "\"_vmType\":\"Bigint\"," | 4337 "\"_vmType\":\"Bigint\"," |
| 4372 "\"class\":{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\"," | 4338 "\"class\":{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\"," |
| 4373 "\"name\":\"_Bigint\",\"_vmName\":\"\"}," | 4339 "\"name\":\"_Bigint\",\"_vmName\":\"\"}," |
| 4374 "\"kind\":\"Int\"," | 4340 "\"kind\":\"Int\"," |
| 4375 "\"id\":\"\",\"valueAsString\":\"44444444444444444444444444444444\"}", | 4341 "\"id\":\"\",\"valueAsString\":\"44444444444444444444444444444444\"}", |
| 4376 buffer); | 4342 buffer); |
| 4377 } | 4343 } |
| 4378 // Double reference | 4344 // Double reference |
| 4379 { | 4345 { |
| 4380 JSONStream js; | 4346 JSONStream js; |
| 4381 const Double& dub = Double::Handle(Double::New(0.1234)); | 4347 const Double& dub = Double::Handle(Double::New(0.1234)); |
| 4382 dub.PrintJSON(&js, true); | 4348 dub.PrintJSON(&js, true); |
| 4383 elideSubstring("classes", js.ToCString(), buffer); | 4349 ElideJSONSubstring("classes", js.ToCString(), buffer); |
| 4384 elideSubstring("objects", buffer, buffer); | 4350 ElideJSONSubstring("objects", buffer, buffer); |
| 4385 elideSubstring("_Double@", buffer, buffer); | 4351 ElideJSONSubstring("_Double@", buffer, buffer); |
| 4386 EXPECT_STREQ( | 4352 EXPECT_STREQ( |
| 4387 "{\"type\":\"@Instance\"," | 4353 "{\"type\":\"@Instance\"," |
| 4388 "\"_vmType\":\"Double\"," | 4354 "\"_vmType\":\"Double\"," |
| 4389 "\"class\":{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\"," | 4355 "\"class\":{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\"," |
| 4390 "\"name\":\"_Double\",\"_vmName\":\"\"}," | 4356 "\"name\":\"_Double\",\"_vmName\":\"\"}," |
| 4391 "\"kind\":\"Double\"," | 4357 "\"kind\":\"Double\"," |
| 4392 "\"id\":\"\",\"valueAsString\":\"0.1234\"}", | 4358 "\"id\":\"\",\"valueAsString\":\"0.1234\"}", |
| 4393 buffer); | 4359 buffer); |
| 4394 } | 4360 } |
| 4395 // String reference | 4361 // String reference |
| 4396 { | 4362 { |
| 4397 JSONStream js; | 4363 JSONStream js; |
| 4398 const String& str = String::Handle(String::New("dw")); | 4364 const String& str = String::Handle(String::New("dw")); |
| 4399 str.PrintJSON(&js, true); | 4365 str.PrintJSON(&js, true); |
| 4400 elideSubstring("classes", js.ToCString(), buffer); | 4366 ElideJSONSubstring("classes", js.ToCString(), buffer); |
| 4401 elideSubstring("objects", buffer, buffer); | 4367 ElideJSONSubstring("objects", buffer, buffer); |
| 4402 elideSubstring("_OneByteString@", buffer, buffer); | 4368 ElideJSONSubstring("_OneByteString@", buffer, buffer); |
| 4403 EXPECT_STREQ( | 4369 EXPECT_STREQ( |
| 4404 "{\"type\":\"@Instance\"," | 4370 "{\"type\":\"@Instance\"," |
| 4405 "\"_vmType\":\"String\"," | 4371 "\"_vmType\":\"String\"," |
| 4406 "\"class\":{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\"," | 4372 "\"class\":{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\"," |
| 4407 "\"name\":\"_OneByteString\",\"_vmName\":\"\"}," | 4373 "\"name\":\"_OneByteString\",\"_vmName\":\"\"}," |
| 4408 "\"kind\":\"String\"," | 4374 "\"kind\":\"String\"," |
| 4409 "\"id\":\"\",\"valueAsString\":\"dw\"}", | 4375 "\"id\":\"\",\"valueAsString\":\"dw\"}", |
| 4410 buffer); | 4376 buffer); |
| 4411 } | 4377 } |
| 4412 // Array reference | 4378 // Array reference |
| 4413 { | 4379 { |
| 4414 JSONStream js; | 4380 JSONStream js; |
| 4415 const Array& array = Array::Handle(Array::New(0)); | 4381 const Array& array = Array::Handle(Array::New(0)); |
| 4416 array.PrintJSON(&js, true); | 4382 array.PrintJSON(&js, true); |
| 4417 elideSubstring("classes", js.ToCString(), buffer); | 4383 ElideJSONSubstring("classes", js.ToCString(), buffer); |
| 4418 elideSubstring("objects", buffer, buffer); | 4384 ElideJSONSubstring("objects", buffer, buffer); |
| 4419 elideSubstring("_List@", buffer, buffer); | 4385 ElideJSONSubstring("_List@", buffer, buffer); |
| 4420 EXPECT_STREQ( | 4386 EXPECT_STREQ( |
| 4421 "{\"type\":\"@Instance\"," | 4387 "{\"type\":\"@Instance\"," |
| 4422 "\"_vmType\":\"Array\"," | 4388 "\"_vmType\":\"Array\"," |
| 4423 "\"class\":{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\"," | 4389 "\"class\":{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\"," |
| 4424 "\"name\":\"_List\",\"_vmName\":\"\"}," | 4390 "\"name\":\"_List\",\"_vmName\":\"\"}," |
| 4425 "\"kind\":\"List\"," | 4391 "\"kind\":\"List\"," |
| 4426 "\"id\":\"\",\"length\":0}", | 4392 "\"id\":\"\",\"length\":0}", |
| 4427 buffer); | 4393 buffer); |
| 4428 } | 4394 } |
| 4429 // GrowableObjectArray reference | 4395 // GrowableObjectArray reference |
| 4430 { | 4396 { |
| 4431 JSONStream js; | 4397 JSONStream js; |
| 4432 const GrowableObjectArray& array = | 4398 const GrowableObjectArray& array = |
| 4433 GrowableObjectArray::Handle(GrowableObjectArray::New()); | 4399 GrowableObjectArray::Handle(GrowableObjectArray::New()); |
| 4434 array.PrintJSON(&js, true); | 4400 array.PrintJSON(&js, true); |
| 4435 elideSubstring("classes", js.ToCString(), buffer); | 4401 ElideJSONSubstring("classes", js.ToCString(), buffer); |
| 4436 elideSubstring("objects", buffer, buffer); | 4402 ElideJSONSubstring("objects", buffer, buffer); |
| 4437 elideSubstring("_GrowableList@", buffer, buffer); | 4403 ElideJSONSubstring("_GrowableList@", buffer, buffer); |
| 4438 EXPECT_STREQ( | 4404 EXPECT_STREQ( |
| 4439 "{\"type\":\"@Instance\"," | 4405 "{\"type\":\"@Instance\"," |
| 4440 "\"_vmType\":\"GrowableObjectArray\"," | 4406 "\"_vmType\":\"GrowableObjectArray\"," |
| 4441 "\"class\":{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\"," | 4407 "\"class\":{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\"," |
| 4442 "\"name\":\"_GrowableList\"," | 4408 "\"name\":\"_GrowableList\"," |
| 4443 "\"_vmName\":\"\"}," | 4409 "\"_vmName\":\"\"}," |
| 4444 "\"kind\":\"List\"," | 4410 "\"kind\":\"List\"," |
| 4445 "\"id\":\"\",\"length\":0}", | 4411 "\"id\":\"\",\"length\":0}", |
| 4446 buffer); | 4412 buffer); |
| 4447 } | 4413 } |
| 4448 // LinkedHashMap reference | 4414 // LinkedHashMap reference |
| 4449 { | 4415 { |
| 4450 JSONStream js; | 4416 JSONStream js; |
| 4451 const LinkedHashMap& array = | 4417 const LinkedHashMap& array = |
| 4452 LinkedHashMap::Handle(LinkedHashMap::NewDefault()); | 4418 LinkedHashMap::Handle(LinkedHashMap::NewDefault()); |
| 4453 array.PrintJSON(&js, true); | 4419 array.PrintJSON(&js, true); |
| 4454 elideSubstring("classes", js.ToCString(), buffer); | 4420 ElideJSONSubstring("classes", js.ToCString(), buffer); |
| 4455 elideSubstring("objects", buffer, buffer); | 4421 ElideJSONSubstring("objects", buffer, buffer); |
| 4456 elideSubstring("_InternalLinkedHashMap@", buffer, buffer); | 4422 ElideJSONSubstring("_InternalLinkedHashMap@", buffer, buffer); |
| 4457 EXPECT_STREQ( | 4423 EXPECT_STREQ( |
| 4458 "{\"type\":\"@Instance\"," | 4424 "{\"type\":\"@Instance\"," |
| 4459 "\"_vmType\":\"LinkedHashMap\"," | 4425 "\"_vmType\":\"LinkedHashMap\"," |
| 4460 "\"class\":{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\"," | 4426 "\"class\":{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\"," |
| 4461 "\"name\":\"_InternalLinkedHashMap\",\"_vmName\":\"\"}," | 4427 "\"name\":\"_InternalLinkedHashMap\",\"_vmName\":\"\"}," |
| 4462 "\"kind\":\"Map\"," | 4428 "\"kind\":\"Map\"," |
| 4463 "\"id\":\"\"," | 4429 "\"id\":\"\"," |
| 4464 "\"length\":0}", | 4430 "\"length\":0}", |
| 4465 buffer); | 4431 buffer); |
| 4466 } | 4432 } |
| 4467 // UserTag reference | 4433 // UserTag reference |
| 4468 { | 4434 { |
| 4469 JSONStream js; | 4435 JSONStream js; |
| 4470 Instance& tag = Instance::Handle(isolate->default_tag()); | 4436 Instance& tag = Instance::Handle(isolate->default_tag()); |
| 4471 tag.PrintJSON(&js, true); | 4437 tag.PrintJSON(&js, true); |
| 4472 elideSubstring("classes", js.ToCString(), buffer); | 4438 ElideJSONSubstring("classes", js.ToCString(), buffer); |
| 4473 elideSubstring("objects", buffer, buffer); | 4439 ElideJSONSubstring("objects", buffer, buffer); |
| 4474 elideSubstring("_UserTag@", buffer, buffer); | 4440 ElideJSONSubstring("_UserTag@", buffer, buffer); |
| 4475 EXPECT_STREQ( | 4441 EXPECT_STREQ( |
| 4476 "{\"type\":\"@Instance\"," | 4442 "{\"type\":\"@Instance\"," |
| 4477 "\"_vmType\":\"UserTag\"," | 4443 "\"_vmType\":\"UserTag\"," |
| 4478 "\"class\":{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\"," | 4444 "\"class\":{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\"," |
| 4479 "\"name\":\"_UserTag\",\"_vmName\":\"\"}," | 4445 "\"name\":\"_UserTag\",\"_vmName\":\"\"}," |
| 4480 "\"kind\":\"PlainInstance\"," | 4446 "\"kind\":\"PlainInstance\"," |
| 4481 "\"id\":\"\"}", | 4447 "\"id\":\"\"}", |
| 4482 buffer); | 4448 buffer); |
| 4483 } | 4449 } |
| 4484 // Type reference | 4450 // Type reference |
| 4485 // TODO(turnidge): Add in all of the other Type siblings. | 4451 // TODO(turnidge): Add in all of the other Type siblings. |
| 4486 { | 4452 { |
| 4487 JSONStream js; | 4453 JSONStream js; |
| 4488 Instance& type = Instance::Handle(isolate->object_store()->bool_type()); | 4454 Instance& type = Instance::Handle(isolate->object_store()->bool_type()); |
| 4489 type.PrintJSON(&js, true); | 4455 type.PrintJSON(&js, true); |
| 4490 elideSubstring("classes", js.ToCString(), buffer); | 4456 ElideJSONSubstring("classes", js.ToCString(), buffer); |
| 4491 elideSubstring("objects", buffer, buffer); | 4457 ElideJSONSubstring("objects", buffer, buffer); |
| 4492 elideSubstring("_Type@", buffer, buffer); | 4458 ElideJSONSubstring("_Type@", buffer, buffer); |
| 4493 EXPECT_STREQ( | 4459 EXPECT_STREQ( |
| 4494 "{\"type\":\"@Instance\"," | 4460 "{\"type\":\"@Instance\"," |
| 4495 "\"_vmType\":\"Type\"," | 4461 "\"_vmType\":\"Type\"," |
| 4496 "\"class\":{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\"," | 4462 "\"class\":{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\"," |
| 4497 "\"name\":\"_Type\",\"_vmName\":\"\"}," | 4463 "\"name\":\"_Type\",\"_vmName\":\"\"}," |
| 4498 "\"kind\":\"Type\"," | 4464 "\"kind\":\"Type\"," |
| 4499 "\"fixedId\":true,\"id\":\"\"," | 4465 "\"fixedId\":true,\"id\":\"\"," |
| 4500 "\"typeClass\":{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\"," | 4466 "\"typeClass\":{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\"," |
| 4501 "\"name\":\"bool\"},\"name\":\"bool\"}", | 4467 "\"name\":\"bool\"},\"name\":\"bool\"}", |
| 4502 buffer); | 4468 buffer); |
| 4503 } | 4469 } |
| 4504 // Null reference | 4470 // Null reference |
| 4505 { | 4471 { |
| 4506 JSONStream js; | 4472 JSONStream js; |
| 4507 Object::null_object().PrintJSON(&js, true); | 4473 Object::null_object().PrintJSON(&js, true); |
| 4474 ElideJSONSubstring("classes", js.ToCString(), buffer); |
| 4508 EXPECT_STREQ( | 4475 EXPECT_STREQ( |
| 4509 "{\"type\":\"@Instance\"," | 4476 "{\"type\":\"@Instance\"," |
| 4510 "\"_vmType\":\"null\"," | 4477 "\"_vmType\":\"null\"," |
| 4478 "\"class\":{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\"," |
| 4479 "\"name\":\"Null\"}," |
| 4511 "\"kind\":\"Null\"," | 4480 "\"kind\":\"Null\"," |
| 4512 "\"fixedId\":true," | 4481 "\"fixedId\":true," |
| 4513 "\"id\":\"objects\\/null\"," | 4482 "\"id\":\"objects\\/null\"," |
| 4514 "\"valueAsString\":\"null\"}", | 4483 "\"valueAsString\":\"null\"}", |
| 4515 js.ToCString()); | 4484 buffer); |
| 4516 } | 4485 } |
| 4517 // Sentinel reference | 4486 // Sentinel reference |
| 4518 { | 4487 { |
| 4519 JSONStream js; | 4488 JSONStream js; |
| 4520 Object::sentinel().PrintJSON(&js, true); | 4489 Object::sentinel().PrintJSON(&js, true); |
| 4521 EXPECT_STREQ( | 4490 EXPECT_STREQ( |
| 4522 "{\"type\":\"Sentinel\"," | 4491 "{\"type\":\"Sentinel\"," |
| 4523 "\"kind\":\"NotInitialized\"," | 4492 "\"kind\":\"NotInitialized\"," |
| 4524 "\"valueAsString\":\"<not initialized>\"}", | 4493 "\"valueAsString\":\"<not initialized>\"}", |
| 4525 js.ToCString()); | 4494 js.ToCString()); |
| 4526 } | 4495 } |
| 4527 // Transition sentinel reference | 4496 // Transition sentinel reference |
| 4528 { | 4497 { |
| 4529 JSONStream js; | 4498 JSONStream js; |
| 4530 Object::transition_sentinel().PrintJSON(&js, true); | 4499 Object::transition_sentinel().PrintJSON(&js, true); |
| 4531 EXPECT_STREQ( | 4500 EXPECT_STREQ( |
| 4532 "{\"type\":\"Sentinel\"," | 4501 "{\"type\":\"Sentinel\"," |
| 4533 "\"kind\":\"BeingInitialized\"," | 4502 "\"kind\":\"BeingInitialized\"," |
| 4534 "\"valueAsString\":\"<being initialized>\"}", | 4503 "\"valueAsString\":\"<being initialized>\"}", |
| 4535 js.ToCString()); | 4504 js.ToCString()); |
| 4536 } | 4505 } |
| 4537 // LiteralToken reference. This is meant to be an example of a | 4506 // LiteralToken reference. This is meant to be an example of a |
| 4538 // "weird" type that isn't usually returned by the VM Service except | 4507 // "weird" type that isn't usually returned by the VM Service except |
| 4539 // when we are doing direct heap inspection. | 4508 // when we are doing direct heap inspection. |
| 4540 { | 4509 { |
| 4541 JSONStream js; | 4510 JSONStream js; |
| 4542 LiteralToken& tok = LiteralToken::Handle(LiteralToken::New()); | 4511 LiteralToken& tok = LiteralToken::Handle(LiteralToken::New()); |
| 4543 tok.PrintJSON(&js, true); | 4512 tok.PrintJSON(&js, true); |
| 4544 elideSubstring("objects", js.ToCString(), buffer); | 4513 ElideJSONSubstring("objects", js.ToCString(), buffer); |
| 4545 EXPECT_STREQ( | 4514 EXPECT_STREQ( |
| 4546 "{\"type\":\"@Object\",\"_vmType\":\"LiteralToken\",\"id\":\"\"}", | 4515 "{\"type\":\"@Object\",\"_vmType\":\"LiteralToken\",\"id\":\"\"}", |
| 4547 buffer); | 4516 buffer); |
| 4548 } | 4517 } |
| 4549 } | 4518 } |
| 4550 | 4519 |
| 4551 | 4520 |
| 4552 TEST_CASE(InstanceEquality) { | 4521 TEST_CASE(InstanceEquality) { |
| 4553 // Test that Instance::OperatorEquals can call a user-defined operator==. | 4522 // Test that Instance::OperatorEquals can call a user-defined operator==. |
| 4554 const char* kScript = | 4523 const char* kScript = |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4783 { | 4752 { |
| 4784 const String& empty = String::Handle(String::New("")); | 4753 const String& empty = String::Handle(String::New("")); |
| 4785 const String* data[3] = { &Symbols::FallThroughError(), | 4754 const String* data[3] = { &Symbols::FallThroughError(), |
| 4786 &empty, | 4755 &empty, |
| 4787 &Symbols::isPaused() }; | 4756 &Symbols::isPaused() }; |
| 4788 CheckConcatAll(data, 3); | 4757 CheckConcatAll(data, 3); |
| 4789 } | 4758 } |
| 4790 } | 4759 } |
| 4791 | 4760 |
| 4792 } // namespace dart | 4761 } // namespace dart |
| OLD | NEW |