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

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

Issue 1723733002: Simplify various name flavors in VM. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 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
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 "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 4204 matching lines...) Expand 10 before | Expand all | Expand 10 after
4215 { 4215 {
4216 JSONStream js; 4216 JSONStream js;
4217 const Integer& smi = Integer::Handle(Integer::New(7)); 4217 const Integer& smi = Integer::Handle(Integer::New(7));
4218 smi.PrintJSON(&js, true); 4218 smi.PrintJSON(&js, true);
4219 ElideJSONSubstring("classes", js.ToCString(), buffer); 4219 ElideJSONSubstring("classes", js.ToCString(), buffer);
4220 ElideJSONSubstring("_Smi@", buffer, buffer); 4220 ElideJSONSubstring("_Smi@", buffer, buffer);
4221 EXPECT_STREQ( 4221 EXPECT_STREQ(
4222 "{\"type\":\"@Instance\"," 4222 "{\"type\":\"@Instance\","
4223 "\"_vmType\":\"Smi\"," 4223 "\"_vmType\":\"Smi\","
4224 "\"class\":{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\"," 4224 "\"class\":{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\","
4225 "\"name\":\"_Smi\"," 4225 "\"name\":\"int\","
4226 "\"_vmName\":\"\"}," 4226 "\"_vmName\":\"\"},"
4227 "\"kind\":\"Int\"," 4227 "\"kind\":\"Int\","
4228 "\"fixedId\":true," 4228 "\"fixedId\":true,"
4229 "\"id\":\"objects\\/int-7\",\"valueAsString\":\"7\"}", 4229 "\"id\":\"objects\\/int-7\",\"valueAsString\":\"7\"}",
4230 buffer); 4230 buffer);
4231 } 4231 }
4232 // Mint reference 4232 // Mint reference
4233 { 4233 {
4234 JSONStream js; 4234 JSONStream js;
4235 const Integer& smi = Integer::Handle(Integer::New(Mint::kMinValue)); 4235 const Integer& smi = Integer::Handle(Integer::New(Mint::kMinValue));
4236 smi.PrintJSON(&js, true); 4236 smi.PrintJSON(&js, true);
4237 ElideJSONSubstring("classes", js.ToCString(), buffer); 4237 ElideJSONSubstring("classes", js.ToCString(), buffer);
4238 ElideJSONSubstring("objects", buffer, buffer); 4238 ElideJSONSubstring("objects", buffer, buffer);
4239 ElideJSONSubstring("_Mint@", buffer, buffer); 4239 ElideJSONSubstring("_Mint@", buffer, buffer);
4240 EXPECT_STREQ( 4240 EXPECT_STREQ(
4241 "{\"type\":\"@Instance\"," 4241 "{\"type\":\"@Instance\","
4242 "\"_vmType\":\"Mint\"," 4242 "\"_vmType\":\"Mint\","
4243 "\"class\":{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\"," 4243 "\"class\":{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\","
4244 "\"name\":\"_Mint\",\"_vmName\":\"\"}," 4244 "\"name\":\"int\",\"_vmName\":\"\"},"
4245 "\"kind\":\"Int\"," 4245 "\"kind\":\"Int\","
4246 "\"id\":\"\",\"valueAsString\":\"-9223372036854775808\"}", 4246 "\"id\":\"\",\"valueAsString\":\"-9223372036854775808\"}",
4247 buffer); 4247 buffer);
4248 } 4248 }
4249 // Bigint reference 4249 // Bigint reference
4250 { 4250 {
4251 JSONStream js; 4251 JSONStream js;
4252 const String& bigint_str = 4252 const String& bigint_str =
4253 String::Handle(String::New("44444444444444444444444444444444")); 4253 String::Handle(String::New("44444444444444444444444444444444"));
4254 const Integer& bigint = Integer::Handle(Integer::New(bigint_str)); 4254 const Integer& bigint = Integer::Handle(Integer::New(bigint_str));
4255 bigint.PrintJSON(&js, true); 4255 bigint.PrintJSON(&js, true);
4256 ElideJSONSubstring("classes", js.ToCString(), buffer); 4256 ElideJSONSubstring("classes", js.ToCString(), buffer);
4257 ElideJSONSubstring("objects", buffer, buffer); 4257 ElideJSONSubstring("objects", buffer, buffer);
4258 ElideJSONSubstring("_Bigint@", buffer, buffer); 4258 ElideJSONSubstring("_Bigint@", buffer, buffer);
4259 EXPECT_STREQ( 4259 EXPECT_STREQ(
4260 "{\"type\":\"@Instance\"," 4260 "{\"type\":\"@Instance\","
4261 "\"_vmType\":\"Bigint\"," 4261 "\"_vmType\":\"Bigint\","
4262 "\"class\":{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\"," 4262 "\"class\":{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\","
4263 "\"name\":\"_Bigint\",\"_vmName\":\"\"}," 4263 "\"name\":\"int\",\"_vmName\":\"\"},"
4264 "\"kind\":\"Int\"," 4264 "\"kind\":\"Int\","
4265 "\"id\":\"\",\"valueAsString\":\"44444444444444444444444444444444\"}", 4265 "\"id\":\"\",\"valueAsString\":\"44444444444444444444444444444444\"}",
4266 buffer); 4266 buffer);
4267 } 4267 }
4268 // Double reference 4268 // Double reference
4269 { 4269 {
4270 JSONStream js; 4270 JSONStream js;
4271 const Double& dub = Double::Handle(Double::New(0.1234)); 4271 const Double& dub = Double::Handle(Double::New(0.1234));
4272 dub.PrintJSON(&js, true); 4272 dub.PrintJSON(&js, true);
4273 ElideJSONSubstring("classes", js.ToCString(), buffer); 4273 ElideJSONSubstring("classes", js.ToCString(), buffer);
4274 ElideJSONSubstring("objects", buffer, buffer); 4274 ElideJSONSubstring("objects", buffer, buffer);
4275 ElideJSONSubstring("_Double@", buffer, buffer); 4275 ElideJSONSubstring("_Double@", buffer, buffer);
4276 EXPECT_STREQ( 4276 EXPECT_STREQ(
4277 "{\"type\":\"@Instance\"," 4277 "{\"type\":\"@Instance\","
4278 "\"_vmType\":\"Double\"," 4278 "\"_vmType\":\"Double\","
4279 "\"class\":{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\"," 4279 "\"class\":{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\","
4280 "\"name\":\"_Double\",\"_vmName\":\"\"}," 4280 "\"name\":\"double\",\"_vmName\":\"\"},"
4281 "\"kind\":\"Double\"," 4281 "\"kind\":\"Double\","
4282 "\"id\":\"\",\"valueAsString\":\"0.1234\"}", 4282 "\"id\":\"\",\"valueAsString\":\"0.1234\"}",
4283 buffer); 4283 buffer);
4284 } 4284 }
4285 // String reference 4285 // String reference
4286 { 4286 {
4287 JSONStream js; 4287 JSONStream js;
4288 const String& str = String::Handle(String::New("dw")); 4288 const String& str = String::Handle(String::New("dw"));
4289 str.PrintJSON(&js, true); 4289 str.PrintJSON(&js, true);
4290 ElideJSONSubstring("classes", js.ToCString(), buffer); 4290 ElideJSONSubstring("classes", js.ToCString(), buffer);
4291 ElideJSONSubstring("objects", buffer, buffer); 4291 ElideJSONSubstring("objects", buffer, buffer);
4292 ElideJSONSubstring("_OneByteString@", buffer, buffer); 4292 ElideJSONSubstring("_OneByteString@", buffer, buffer);
4293 EXPECT_STREQ( 4293 EXPECT_STREQ(
4294 "{\"type\":\"@Instance\"," 4294 "{\"type\":\"@Instance\","
4295 "\"_vmType\":\"String\"," 4295 "\"_vmType\":\"String\","
4296 "\"class\":{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\"," 4296 "\"class\":{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\","
4297 "\"name\":\"_OneByteString\",\"_vmName\":\"\"}," 4297 "\"name\":\"String\",\"_vmName\":\"\"},"
4298 "\"kind\":\"String\"," 4298 "\"kind\":\"String\","
4299 "\"id\":\"\",\"length\":2,\"valueAsString\":\"dw\"}", 4299 "\"id\":\"\",\"length\":2,\"valueAsString\":\"dw\"}",
4300 buffer); 4300 buffer);
4301 } 4301 }
4302 // Array reference 4302 // Array reference
4303 { 4303 {
4304 JSONStream js; 4304 JSONStream js;
4305 const Array& array = Array::Handle(Array::New(0)); 4305 const Array& array = Array::Handle(Array::New(0));
4306 array.PrintJSON(&js, true); 4306 array.PrintJSON(&js, true);
4307 ElideJSONSubstring("classes", js.ToCString(), buffer); 4307 ElideJSONSubstring("classes", js.ToCString(), buffer);
4308 ElideJSONSubstring("objects", buffer, buffer); 4308 ElideJSONSubstring("objects", buffer, buffer);
4309 ElideJSONSubstring("_List@", buffer, buffer); 4309 ElideJSONSubstring("_List@", buffer, buffer);
4310 EXPECT_STREQ( 4310 EXPECT_STREQ(
4311 "{\"type\":\"@Instance\"," 4311 "{\"type\":\"@Instance\","
4312 "\"_vmType\":\"Array\"," 4312 "\"_vmType\":\"Array\","
4313 "\"class\":{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\"," 4313 "\"class\":{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\","
4314 "\"name\":\"_List\",\"_vmName\":\"\"}," 4314 "\"name\":\"List\",\"_vmName\":\"\"},"
4315 "\"kind\":\"List\"," 4315 "\"kind\":\"List\","
4316 "\"id\":\"\",\"length\":0}", 4316 "\"id\":\"\",\"length\":0}",
4317 buffer); 4317 buffer);
4318 } 4318 }
4319 // GrowableObjectArray reference 4319 // GrowableObjectArray reference
4320 { 4320 {
4321 JSONStream js; 4321 JSONStream js;
4322 const GrowableObjectArray& array = 4322 const GrowableObjectArray& array =
4323 GrowableObjectArray::Handle(GrowableObjectArray::New()); 4323 GrowableObjectArray::Handle(GrowableObjectArray::New());
4324 array.PrintJSON(&js, true); 4324 array.PrintJSON(&js, true);
4325 ElideJSONSubstring("classes", js.ToCString(), buffer); 4325 ElideJSONSubstring("classes", js.ToCString(), buffer);
4326 ElideJSONSubstring("objects", buffer, buffer); 4326 ElideJSONSubstring("objects", buffer, buffer);
4327 ElideJSONSubstring("_GrowableList@", buffer, buffer); 4327 ElideJSONSubstring("_GrowableList@", buffer, buffer);
4328 EXPECT_STREQ( 4328 EXPECT_STREQ(
4329 "{\"type\":\"@Instance\"," 4329 "{\"type\":\"@Instance\","
4330 "\"_vmType\":\"GrowableObjectArray\"," 4330 "\"_vmType\":\"GrowableObjectArray\","
4331 "\"class\":{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\"," 4331 "\"class\":{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\","
4332 "\"name\":\"_GrowableList\"," 4332 "\"name\":\"List\","
4333 "\"_vmName\":\"\"}," 4333 "\"_vmName\":\"\"},"
4334 "\"kind\":\"List\"," 4334 "\"kind\":\"List\","
4335 "\"id\":\"\",\"length\":0}", 4335 "\"id\":\"\",\"length\":0}",
4336 buffer); 4336 buffer);
4337 } 4337 }
4338 // LinkedHashMap reference 4338 // LinkedHashMap reference
4339 { 4339 {
4340 JSONStream js; 4340 JSONStream js;
4341 const LinkedHashMap& array = 4341 const LinkedHashMap& array =
4342 LinkedHashMap::Handle(LinkedHashMap::NewDefault()); 4342 LinkedHashMap::Handle(LinkedHashMap::NewDefault());
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
4685 } 4685 }
4686 } 4686 }
4687 4687
4688 4688
4689 struct TestResult { 4689 struct TestResult {
4690 const char* in; 4690 const char* in;
4691 const char* out; 4691 const char* out;
4692 }; 4692 };
4693 4693
4694 4694
4695 VM_TEST_CASE(String_IdentifierPrettyName) { 4695 VM_TEST_CASE(String_ScrubName) {
4696 TestResult tests[] = { 4696 TestResult tests[] = {
4697 {"(dynamic, dynamic) => void", "(dynamic, dynamic) => void"}, 4697 {"(dynamic, dynamic) => void", "(dynamic, dynamic) => void"},
4698 {"_List@915557746", "_List"}, 4698 {"_List@915557746", "_List"},
4699 {"_HashMap@600006304<K, V>(dynamic) => V", "_HashMap<K, V>(dynamic) => V"}, 4699 {"_HashMap@600006304<K, V>(dynamic) => V", "_HashMap<K, V>(dynamic) => V"},
4700 {"set:foo", "foo="}, 4700 {"set:foo", "foo="},
4701 {"get:foo", "foo"}, 4701 {"get:foo", "foo"},
4702 {"_ReceivePortImpl@709387912", "_ReceivePortImpl"}, 4702 {"_ReceivePortImpl@709387912", "_ReceivePortImpl"},
4703 {"_ReceivePortImpl@709387912._internal@709387912", 4703 {"_ReceivePortImpl@709387912._internal@709387912",
4704 "_ReceivePortImpl._internal"}, 4704 "_ReceivePortImpl._internal"},
4705 {"_C@6328321&_E@6328321&_F@6328321", "_C&_E&_F"}, 4705 {"_C@6328321&_E@6328321&_F@6328321", "_C&_E&_F"},
4706 {"List.", "List"}, 4706 {"List.", "List"},
4707 {"get:foo@6328321", "foo"}, 4707 {"get:foo@6328321", "foo"},
4708 {"_MyClass@6328321.", "_MyClass"}, 4708 {"_MyClass@6328321.", "_MyClass"},
4709 {"_MyClass@6328321.named", "_MyClass.named"}, 4709 {"_MyClass@6328321.named", "_MyClass.named"},
4710 }; 4710 };
4711 String& test = String::Handle(); 4711 String& test = String::Handle();
4712 String& result = String::Handle(); 4712 String& result = String::Handle();
4713 for (size_t i = 0; i < ARRAY_SIZE(tests); i++) { 4713 for (size_t i = 0; i < ARRAY_SIZE(tests); i++) {
4714 test = String::New(tests[i].in); 4714 test = String::New(tests[i].in);
4715 result = String::IdentifierPrettyName(test); 4715 result = String::ScrubName(test);
4716 EXPECT_STREQ(tests[i].out, result.ToCString()); 4716 EXPECT_STREQ(tests[i].out, result.ToCString());
4717 } 4717 }
4718 } 4718 }
4719 4719
4720 } // namespace dart 4720 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698