| 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 13 matching lines...) Expand all Loading... |
| 24 | 24 |
| 25 static RawClass* CreateDummyClass(const String& class_name, | 25 static RawClass* CreateDummyClass(const String& class_name, |
| 26 const Script& script) { | 26 const Script& script) { |
| 27 const Class& cls = Class::Handle(Class::New( | 27 const Class& cls = Class::Handle(Class::New( |
| 28 Library::Handle(), class_name, script, TokenPosition::kNoSource)); | 28 Library::Handle(), class_name, script, TokenPosition::kNoSource)); |
| 29 cls.set_is_synthesized_class(); // Dummy class for testing. | 29 cls.set_is_synthesized_class(); // Dummy class for testing. |
| 30 return cls.raw(); | 30 return cls.raw(); |
| 31 } | 31 } |
| 32 | 32 |
| 33 | 33 |
| 34 VM_TEST_CASE(Class) { | 34 ISOLATE_UNIT_TEST_CASE(Class) { |
| 35 // Allocate the class first. | 35 // Allocate the class first. |
| 36 const String& class_name = String::Handle(Symbols::New(thread, "MyClass")); | 36 const String& class_name = String::Handle(Symbols::New(thread, "MyClass")); |
| 37 const Script& script = Script::Handle(); | 37 const Script& script = Script::Handle(); |
| 38 const Class& cls = Class::Handle(CreateDummyClass(class_name, script)); | 38 const Class& cls = Class::Handle(CreateDummyClass(class_name, script)); |
| 39 | 39 |
| 40 // Class has no fields and no functions yet. | 40 // Class has no fields and no functions yet. |
| 41 EXPECT_EQ(Array::Handle(cls.fields()).Length(), 0); | 41 EXPECT_EQ(Array::Handle(cls.fields()).Length(), 0); |
| 42 EXPECT_EQ(Array::Handle(cls.functions()).Length(), 0); | 42 EXPECT_EQ(Array::Handle(cls.functions()).Length(), 0); |
| 43 | 43 |
| 44 // Setup the interfaces in the class. | 44 // Setup the interfaces in the class. |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 EXPECT(!function.HasOptionalParameters()); | 132 EXPECT(!function.HasOptionalParameters()); |
| 133 | 133 |
| 134 function_name = String::New("bar"); | 134 function_name = String::New("bar"); |
| 135 function = cls.LookupDynamicFunction(function_name); | 135 function = cls.LookupDynamicFunction(function_name); |
| 136 EXPECT(!function.IsNull()); | 136 EXPECT(!function.IsNull()); |
| 137 EXPECT_EQ(kNumFixedParameters, function.num_fixed_parameters()); | 137 EXPECT_EQ(kNumFixedParameters, function.num_fixed_parameters()); |
| 138 EXPECT_EQ(kNumOptionalParameters, function.NumOptionalParameters()); | 138 EXPECT_EQ(kNumOptionalParameters, function.NumOptionalParameters()); |
| 139 } | 139 } |
| 140 | 140 |
| 141 | 141 |
| 142 VM_TEST_CASE(TypeArguments) { | 142 ISOLATE_UNIT_TEST_CASE(TypeArguments) { |
| 143 const Type& type1 = Type::Handle(Type::Double()); | 143 const Type& type1 = Type::Handle(Type::Double()); |
| 144 const Type& type2 = Type::Handle(Type::StringType()); | 144 const Type& type2 = Type::Handle(Type::StringType()); |
| 145 const TypeArguments& type_arguments1 = | 145 const TypeArguments& type_arguments1 = |
| 146 TypeArguments::Handle(TypeArguments::New(2)); | 146 TypeArguments::Handle(TypeArguments::New(2)); |
| 147 type_arguments1.SetTypeAt(0, type1); | 147 type_arguments1.SetTypeAt(0, type1); |
| 148 type_arguments1.SetTypeAt(1, type2); | 148 type_arguments1.SetTypeAt(1, type2); |
| 149 const TypeArguments& type_arguments2 = | 149 const TypeArguments& type_arguments2 = |
| 150 TypeArguments::Handle(TypeArguments::New(2)); | 150 TypeArguments::Handle(TypeArguments::New(2)); |
| 151 type_arguments2.SetTypeAt(0, type1); | 151 type_arguments2.SetTypeAt(0, type1); |
| 152 type_arguments2.SetTypeAt(1, type2); | 152 type_arguments2.SetTypeAt(1, type2); |
| 153 EXPECT_NE(type_arguments1.raw(), type_arguments2.raw()); | 153 EXPECT_NE(type_arguments1.raw(), type_arguments2.raw()); |
| 154 OS::Print("1: %s\n", type_arguments1.ToCString()); | 154 OS::Print("1: %s\n", type_arguments1.ToCString()); |
| 155 OS::Print("2: %s\n", type_arguments2.ToCString()); | 155 OS::Print("2: %s\n", type_arguments2.ToCString()); |
| 156 EXPECT(type_arguments1.Equals(type_arguments2)); | 156 EXPECT(type_arguments1.Equals(type_arguments2)); |
| 157 TypeArguments& type_arguments3 = TypeArguments::Handle(); | 157 TypeArguments& type_arguments3 = TypeArguments::Handle(); |
| 158 type_arguments1.Canonicalize(); | 158 type_arguments1.Canonicalize(); |
| 159 type_arguments3 ^= type_arguments2.Canonicalize(); | 159 type_arguments3 ^= type_arguments2.Canonicalize(); |
| 160 EXPECT_EQ(type_arguments1.raw(), type_arguments3.raw()); | 160 EXPECT_EQ(type_arguments1.raw(), type_arguments3.raw()); |
| 161 } | 161 } |
| 162 | 162 |
| 163 | 163 |
| 164 VM_TEST_CASE(TokenStream) { | 164 ISOLATE_UNIT_TEST_CASE(TokenStream) { |
| 165 Zone* zone = Thread::Current()->zone(); | 165 Zone* zone = Thread::Current()->zone(); |
| 166 String& source = String::Handle(zone, String::New("= ( 9 , .")); | 166 String& source = String::Handle(zone, String::New("= ( 9 , .")); |
| 167 String& private_key = String::Handle(zone, String::New("")); | 167 String& private_key = String::Handle(zone, String::New("")); |
| 168 const TokenStream& token_stream = | 168 const TokenStream& token_stream = |
| 169 TokenStream::Handle(zone, TokenStream::New(source, private_key, false)); | 169 TokenStream::Handle(zone, TokenStream::New(source, private_key, false)); |
| 170 TokenStream::Iterator iterator(zone, token_stream, TokenPosition::kMinSource); | 170 TokenStream::Iterator iterator(zone, token_stream, TokenPosition::kMinSource); |
| 171 iterator.Advance(); // Advance to '(' token. | 171 iterator.Advance(); // Advance to '(' token. |
| 172 EXPECT_EQ(Token::kLPAREN, iterator.CurrentTokenKind()); | 172 EXPECT_EQ(Token::kLPAREN, iterator.CurrentTokenKind()); |
| 173 iterator.Advance(); | 173 iterator.Advance(); |
| 174 iterator.Advance(); | 174 iterator.Advance(); |
| 175 iterator.Advance(); // Advance to '.' token. | 175 iterator.Advance(); // Advance to '.' token. |
| 176 EXPECT_EQ(Token::kPERIOD, iterator.CurrentTokenKind()); | 176 EXPECT_EQ(Token::kPERIOD, iterator.CurrentTokenKind()); |
| 177 iterator.Advance(); // Advance to end of stream. | 177 iterator.Advance(); // Advance to end of stream. |
| 178 EXPECT_EQ(Token::kEOS, iterator.CurrentTokenKind()); | 178 EXPECT_EQ(Token::kEOS, iterator.CurrentTokenKind()); |
| 179 } | 179 } |
| 180 | 180 |
| 181 | 181 |
| 182 VM_TEST_CASE(GenerateExactSource) { | 182 ISOLATE_UNIT_TEST_CASE(GenerateExactSource) { |
| 183 // Verify the exact formatting of generated sources. | 183 // Verify the exact formatting of generated sources. |
| 184 const char* kScriptChars = | 184 const char* kScriptChars = |
| 185 "\n" | 185 "\n" |
| 186 "class A {\n" | 186 "class A {\n" |
| 187 " static bar() { return 42; }\n" | 187 " static bar() { return 42; }\n" |
| 188 " static fly() { return 5; }\n" | 188 " static fly() { return 5; }\n" |
| 189 " void catcher(x) {\n" | 189 " void catcher(x) {\n" |
| 190 " try {\n" | 190 " try {\n" |
| 191 " if (x is! List) {\n" | 191 " if (x is! List) {\n" |
| 192 " for (int i = 0; i < x; i++) {\n" | 192 " for (int i = 0; i < x; i++) {\n" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 EXPECT(!cls.IsNull()); | 240 EXPECT(!cls.IsNull()); |
| 241 const TokenPosition end_token_pos = cls.ComputeEndTokenPos(); | 241 const TokenPosition end_token_pos = cls.ComputeEndTokenPos(); |
| 242 const Script& scr = Script::Handle(cls.script()); | 242 const Script& scr = Script::Handle(cls.script()); |
| 243 intptr_t line; | 243 intptr_t line; |
| 244 intptr_t col; | 244 intptr_t col; |
| 245 scr.GetTokenLocation(end_token_pos, &line, &col); | 245 scr.GetTokenLocation(end_token_pos, &line, &col); |
| 246 EXPECT(line == 10 && col == 1); | 246 EXPECT(line == 10 && col == 1); |
| 247 } | 247 } |
| 248 | 248 |
| 249 | 249 |
| 250 VM_TEST_CASE(InstanceClass) { | 250 ISOLATE_UNIT_TEST_CASE(InstanceClass) { |
| 251 // Allocate the class first. | 251 // Allocate the class first. |
| 252 String& class_name = String::Handle(Symbols::New(thread, "EmptyClass")); | 252 String& class_name = String::Handle(Symbols::New(thread, "EmptyClass")); |
| 253 Script& script = Script::Handle(); | 253 Script& script = Script::Handle(); |
| 254 const Class& empty_class = | 254 const Class& empty_class = |
| 255 Class::Handle(CreateDummyClass(class_name, script)); | 255 Class::Handle(CreateDummyClass(class_name, script)); |
| 256 | 256 |
| 257 // EmptyClass has no fields and no functions. | 257 // EmptyClass has no fields and no functions. |
| 258 EXPECT_EQ(Array::Handle(empty_class.fields()).Length(), 0); | 258 EXPECT_EQ(Array::Handle(empty_class.fields()).Length(), 0); |
| 259 EXPECT_EQ(Array::Handle(empty_class.functions()).Length(), 0); | 259 EXPECT_EQ(Array::Handle(empty_class.functions()).Length(), 0); |
| 260 | 260 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 286 intptr_t header_size = sizeof(RawObject); | 286 intptr_t header_size = sizeof(RawObject); |
| 287 EXPECT_EQ(Utils::RoundUp((header_size + (1 * kWordSize)), kObjectAlignment), | 287 EXPECT_EQ(Utils::RoundUp((header_size + (1 * kWordSize)), kObjectAlignment), |
| 288 one_field_class.instance_size()); | 288 one_field_class.instance_size()); |
| 289 EXPECT_EQ(header_size, field.Offset()); | 289 EXPECT_EQ(header_size, field.Offset()); |
| 290 EXPECT(!one_field_class.is_implemented()); | 290 EXPECT(!one_field_class.is_implemented()); |
| 291 one_field_class.set_is_implemented(); | 291 one_field_class.set_is_implemented(); |
| 292 EXPECT(one_field_class.is_implemented()); | 292 EXPECT(one_field_class.is_implemented()); |
| 293 } | 293 } |
| 294 | 294 |
| 295 | 295 |
| 296 VM_TEST_CASE(Smi) { | 296 ISOLATE_UNIT_TEST_CASE(Smi) { |
| 297 const Smi& smi = Smi::Handle(Smi::New(5)); | 297 const Smi& smi = Smi::Handle(Smi::New(5)); |
| 298 Object& smi_object = Object::Handle(smi.raw()); | 298 Object& smi_object = Object::Handle(smi.raw()); |
| 299 EXPECT(smi.IsSmi()); | 299 EXPECT(smi.IsSmi()); |
| 300 EXPECT(smi_object.IsSmi()); | 300 EXPECT(smi_object.IsSmi()); |
| 301 EXPECT_EQ(5, smi.Value()); | 301 EXPECT_EQ(5, smi.Value()); |
| 302 const Object& object = Object::Handle(); | 302 const Object& object = Object::Handle(); |
| 303 EXPECT(!object.IsSmi()); | 303 EXPECT(!object.IsSmi()); |
| 304 smi_object = Object::null(); | 304 smi_object = Object::null(); |
| 305 EXPECT(!smi_object.IsSmi()); | 305 EXPECT(!smi_object.IsSmi()); |
| 306 | 306 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 Bigint& big1 = Bigint::Handle(Bigint::NewFromCString("10000000000000000000")); | 347 Bigint& big1 = Bigint::Handle(Bigint::NewFromCString("10000000000000000000")); |
| 348 Bigint& big2 = | 348 Bigint& big2 = |
| 349 Bigint::Handle(Bigint::NewFromCString("-10000000000000000000")); | 349 Bigint::Handle(Bigint::NewFromCString("-10000000000000000000")); |
| 350 EXPECT_EQ(-1, a.CompareWith(big1)); | 350 EXPECT_EQ(-1, a.CompareWith(big1)); |
| 351 EXPECT_EQ(1, a.CompareWith(big2)); | 351 EXPECT_EQ(1, a.CompareWith(big2)); |
| 352 EXPECT_EQ(-1, c.CompareWith(big1)); | 352 EXPECT_EQ(-1, c.CompareWith(big1)); |
| 353 EXPECT_EQ(1, c.CompareWith(big2)); | 353 EXPECT_EQ(1, c.CompareWith(big2)); |
| 354 } | 354 } |
| 355 | 355 |
| 356 | 356 |
| 357 VM_TEST_CASE(StringCompareTo) { | 357 ISOLATE_UNIT_TEST_CASE(StringCompareTo) { |
| 358 const String& abcd = String::Handle(String::New("abcd")); | 358 const String& abcd = String::Handle(String::New("abcd")); |
| 359 const String& abce = String::Handle(String::New("abce")); | 359 const String& abce = String::Handle(String::New("abce")); |
| 360 EXPECT_EQ(0, abcd.CompareTo(abcd)); | 360 EXPECT_EQ(0, abcd.CompareTo(abcd)); |
| 361 EXPECT_EQ(0, abce.CompareTo(abce)); | 361 EXPECT_EQ(0, abce.CompareTo(abce)); |
| 362 EXPECT(abcd.CompareTo(abce) < 0); | 362 EXPECT(abcd.CompareTo(abce) < 0); |
| 363 EXPECT(abce.CompareTo(abcd) > 0); | 363 EXPECT(abce.CompareTo(abcd) > 0); |
| 364 | 364 |
| 365 const int kMonkeyLen = 4; | 365 const int kMonkeyLen = 4; |
| 366 const uint8_t monkey_utf8[kMonkeyLen] = {0xf0, 0x9f, 0x90, 0xb5}; | 366 const uint8_t monkey_utf8[kMonkeyLen] = {0xf0, 0x9f, 0x90, 0xb5}; |
| 367 const String& monkey_face = | 367 const String& monkey_face = |
| (...skipping 22 matching lines...) Expand all Loading... |
| 390 EXPECT(abce.CompareTo(monkey_face) < 0); | 390 EXPECT(abce.CompareTo(monkey_face) < 0); |
| 391 EXPECT(abcd.CompareTo(domino) < 0); | 391 EXPECT(abcd.CompareTo(domino) < 0); |
| 392 EXPECT(abce.CompareTo(domino) < 0); | 392 EXPECT(abce.CompareTo(domino) < 0); |
| 393 EXPECT(domino.CompareTo(abcd) > 0); | 393 EXPECT(domino.CompareTo(abcd) > 0); |
| 394 EXPECT(domino.CompareTo(abcd) > 0); | 394 EXPECT(domino.CompareTo(abcd) > 0); |
| 395 EXPECT(monkey_face.CompareTo(abce) > 0); | 395 EXPECT(monkey_face.CompareTo(abce) > 0); |
| 396 EXPECT(monkey_face.CompareTo(abce) > 0); | 396 EXPECT(monkey_face.CompareTo(abce) > 0); |
| 397 } | 397 } |
| 398 | 398 |
| 399 | 399 |
| 400 VM_TEST_CASE(StringEncodeIRI) { | 400 ISOLATE_UNIT_TEST_CASE(StringEncodeIRI) { |
| 401 const char* kInput = | 401 const char* kInput = |
| 402 "file:///usr/local/johnmccutchan/workspace/dart-repo/dart/test.dart"; | 402 "file:///usr/local/johnmccutchan/workspace/dart-repo/dart/test.dart"; |
| 403 const char* kOutput = | 403 const char* kOutput = |
| 404 "file%3A%2F%2F%2Fusr%2Flocal%2Fjohnmccutchan%2Fworkspace%2F" | 404 "file%3A%2F%2F%2Fusr%2Flocal%2Fjohnmccutchan%2Fworkspace%2F" |
| 405 "dart-repo%2Fdart%2Ftest.dart"; | 405 "dart-repo%2Fdart%2Ftest.dart"; |
| 406 const String& input = String::Handle(String::New(kInput)); | 406 const String& input = String::Handle(String::New(kInput)); |
| 407 const char* encoded = String::EncodeIRI(input); | 407 const char* encoded = String::EncodeIRI(input); |
| 408 EXPECT(strcmp(encoded, kOutput) == 0); | 408 EXPECT(strcmp(encoded, kOutput) == 0); |
| 409 } | 409 } |
| 410 | 410 |
| 411 | 411 |
| 412 VM_TEST_CASE(StringDecodeIRI) { | 412 ISOLATE_UNIT_TEST_CASE(StringDecodeIRI) { |
| 413 const char* kOutput = | 413 const char* kOutput = |
| 414 "file:///usr/local/johnmccutchan/workspace/dart-repo/dart/test.dart"; | 414 "file:///usr/local/johnmccutchan/workspace/dart-repo/dart/test.dart"; |
| 415 const char* kInput = | 415 const char* kInput = |
| 416 "file%3A%2F%2F%2Fusr%2Flocal%2Fjohnmccutchan%2Fworkspace%2F" | 416 "file%3A%2F%2F%2Fusr%2Flocal%2Fjohnmccutchan%2Fworkspace%2F" |
| 417 "dart-repo%2Fdart%2Ftest.dart"; | 417 "dart-repo%2Fdart%2Ftest.dart"; |
| 418 const String& input = String::Handle(String::New(kInput)); | 418 const String& input = String::Handle(String::New(kInput)); |
| 419 const String& output = String::Handle(String::New(kOutput)); | 419 const String& output = String::Handle(String::New(kOutput)); |
| 420 const String& decoded = String::Handle(String::DecodeIRI(input)); | 420 const String& decoded = String::Handle(String::DecodeIRI(input)); |
| 421 EXPECT(output.Equals(decoded)); | 421 EXPECT(output.Equals(decoded)); |
| 422 } | 422 } |
| 423 | 423 |
| 424 | 424 |
| 425 VM_TEST_CASE(StringDecodeIRIInvalid) { | 425 ISOLATE_UNIT_TEST_CASE(StringDecodeIRIInvalid) { |
| 426 String& input = String::Handle(); | 426 String& input = String::Handle(); |
| 427 input = String::New("file%"); | 427 input = String::New("file%"); |
| 428 String& decoded = String::Handle(); | 428 String& decoded = String::Handle(); |
| 429 decoded = String::DecodeIRI(input); | 429 decoded = String::DecodeIRI(input); |
| 430 EXPECT(decoded.IsNull()); | 430 EXPECT(decoded.IsNull()); |
| 431 input = String::New("file%3"); | 431 input = String::New("file%3"); |
| 432 decoded = String::DecodeIRI(input); | 432 decoded = String::DecodeIRI(input); |
| 433 EXPECT(decoded.IsNull()); | 433 EXPECT(decoded.IsNull()); |
| 434 input = String::New("file%3g"); | 434 input = String::New("file%3g"); |
| 435 decoded = String::DecodeIRI(input); | 435 decoded = String::DecodeIRI(input); |
| 436 EXPECT(decoded.IsNull()); | 436 EXPECT(decoded.IsNull()); |
| 437 } | 437 } |
| 438 | 438 |
| 439 | 439 |
| 440 VM_TEST_CASE(StringIRITwoByte) { | 440 ISOLATE_UNIT_TEST_CASE(StringIRITwoByte) { |
| 441 const intptr_t kInputLen = 3; | 441 const intptr_t kInputLen = 3; |
| 442 const uint16_t kInput[kInputLen] = {'x', '/', 256}; | 442 const uint16_t kInput[kInputLen] = {'x', '/', 256}; |
| 443 const String& input = String::Handle(String::FromUTF16(kInput, kInputLen)); | 443 const String& input = String::Handle(String::FromUTF16(kInput, kInputLen)); |
| 444 const intptr_t kOutputLen = 10; | 444 const intptr_t kOutputLen = 10; |
| 445 const uint16_t kOutput[kOutputLen] = {'x', '%', '2', 'F', '%', | 445 const uint16_t kOutput[kOutputLen] = {'x', '%', '2', 'F', '%', |
| 446 'C', '4', '%', '8', '0'}; | 446 'C', '4', '%', '8', '0'}; |
| 447 const String& output = String::Handle(String::FromUTF16(kOutput, kOutputLen)); | 447 const String& output = String::Handle(String::FromUTF16(kOutput, kOutputLen)); |
| 448 const String& encoded = String::Handle(String::New(String::EncodeIRI(input))); | 448 const String& encoded = String::Handle(String::New(String::EncodeIRI(input))); |
| 449 EXPECT(output.Equals(encoded)); | 449 EXPECT(output.Equals(encoded)); |
| 450 const String& decoded = String::Handle(String::DecodeIRI(output)); | 450 const String& decoded = String::Handle(String::DecodeIRI(output)); |
| 451 EXPECT(input.Equals(decoded)); | 451 EXPECT(input.Equals(decoded)); |
| 452 } | 452 } |
| 453 | 453 |
| 454 | 454 |
| 455 VM_TEST_CASE(Mint) { | 455 ISOLATE_UNIT_TEST_CASE(Mint) { |
| 456 // On 64-bit architectures a Smi is stored in a 64 bit word. A Midint cannot | 456 // On 64-bit architectures a Smi is stored in a 64 bit word. A Midint cannot |
| 457 // be allocated if it does fit into a Smi. | 457 // be allocated if it does fit into a Smi. |
| 458 #if !defined(ARCH_IS_64_BIT) | 458 #if !defined(ARCH_IS_64_BIT) |
| 459 { | 459 { |
| 460 Mint& med = Mint::Handle(); | 460 Mint& med = Mint::Handle(); |
| 461 EXPECT(med.IsNull()); | 461 EXPECT(med.IsNull()); |
| 462 int64_t v = DART_2PART_UINT64_C(1, 0); | 462 int64_t v = DART_2PART_UINT64_C(1, 0); |
| 463 med ^= Integer::New(v); | 463 med ^= Integer::New(v); |
| 464 EXPECT_EQ(v, med.value()); | 464 EXPECT_EQ(v, med.value()); |
| 465 const String& smi_str = String::Handle(String::New("1")); | 465 const String& smi_str = String::Handle(String::New("1")); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 mint1 ^= Integer::NewCanonical(mint_string); | 519 mint1 ^= Integer::NewCanonical(mint_string); |
| 520 Mint& mint2 = Mint::Handle(); | 520 Mint& mint2 = Mint::Handle(); |
| 521 mint2 ^= Integer::NewCanonical(mint_string); | 521 mint2 ^= Integer::NewCanonical(mint_string); |
| 522 EXPECT_EQ(mint1.value(), mint_value); | 522 EXPECT_EQ(mint1.value(), mint_value); |
| 523 EXPECT_EQ(mint2.value(), mint_value); | 523 EXPECT_EQ(mint2.value(), mint_value); |
| 524 EXPECT_EQ(mint1.raw(), mint2.raw()); | 524 EXPECT_EQ(mint1.raw(), mint2.raw()); |
| 525 #endif | 525 #endif |
| 526 } | 526 } |
| 527 | 527 |
| 528 | 528 |
| 529 VM_TEST_CASE(Double) { | 529 ISOLATE_UNIT_TEST_CASE(Double) { |
| 530 { | 530 { |
| 531 const double dbl_const = 5.0; | 531 const double dbl_const = 5.0; |
| 532 const Double& dbl = Double::Handle(Double::New(dbl_const)); | 532 const Double& dbl = Double::Handle(Double::New(dbl_const)); |
| 533 Object& dbl_object = Object::Handle(dbl.raw()); | 533 Object& dbl_object = Object::Handle(dbl.raw()); |
| 534 EXPECT(dbl.IsDouble()); | 534 EXPECT(dbl.IsDouble()); |
| 535 EXPECT(dbl_object.IsDouble()); | 535 EXPECT(dbl_object.IsDouble()); |
| 536 EXPECT_EQ(dbl_const, dbl.value()); | 536 EXPECT_EQ(dbl_const, dbl.value()); |
| 537 } | 537 } |
| 538 | 538 |
| 539 { | 539 { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 603 EXPECT_EQ(2.0, dbl1.value()); | 603 EXPECT_EQ(2.0, dbl1.value()); |
| 604 | 604 |
| 605 // Disallow legacy form. | 605 // Disallow legacy form. |
| 606 const String& dbl_str2 = String::Handle(String::New("2.0d")); | 606 const String& dbl_str2 = String::Handle(String::New("2.0d")); |
| 607 const Double& dbl2 = Double::Handle(Double::New(dbl_str2)); | 607 const Double& dbl2 = Double::Handle(Double::New(dbl_str2)); |
| 608 EXPECT(dbl2.IsNull()); | 608 EXPECT(dbl2.IsNull()); |
| 609 } | 609 } |
| 610 } | 610 } |
| 611 | 611 |
| 612 | 612 |
| 613 VM_TEST_CASE(Bigint) { | 613 ISOLATE_UNIT_TEST_CASE(Bigint) { |
| 614 Bigint& b = Bigint::Handle(); | 614 Bigint& b = Bigint::Handle(); |
| 615 EXPECT(b.IsNull()); | 615 EXPECT(b.IsNull()); |
| 616 const char* cstr = "18446744073709551615000"; | 616 const char* cstr = "18446744073709551615000"; |
| 617 const String& test = String::Handle(String::New(cstr)); | 617 const String& test = String::Handle(String::New(cstr)); |
| 618 b ^= Integer::NewCanonical(test); | 618 b ^= Integer::NewCanonical(test); |
| 619 const char* str = b.ToCString(); | 619 const char* str = b.ToCString(); |
| 620 EXPECT_STREQ(cstr, str); | 620 EXPECT_STREQ(cstr, str); |
| 621 | 621 |
| 622 int64_t t64 = DART_2PART_UINT64_C(1, 0); | 622 int64_t t64 = DART_2PART_UINT64_C(1, 0); |
| 623 Bigint& big = Bigint::Handle(Bigint::NewFromInt64(t64)); | 623 Bigint& big = Bigint::Handle(Bigint::NewFromInt64(t64)); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 642 Smi& smi2 = Smi::Handle(Smi::New(-2)); | 642 Smi& smi2 = Smi::Handle(Smi::New(-2)); |
| 643 | 643 |
| 644 EXPECT_EQ(-1, smi1.CompareWith(big1)); | 644 EXPECT_EQ(-1, smi1.CompareWith(big1)); |
| 645 EXPECT_EQ(-1, smi2.CompareWith(big1)); | 645 EXPECT_EQ(-1, smi2.CompareWith(big1)); |
| 646 | 646 |
| 647 EXPECT_EQ(1, smi1.CompareWith(big3)); | 647 EXPECT_EQ(1, smi1.CompareWith(big3)); |
| 648 EXPECT_EQ(1, smi2.CompareWith(big3)); | 648 EXPECT_EQ(1, smi2.CompareWith(big3)); |
| 649 } | 649 } |
| 650 | 650 |
| 651 | 651 |
| 652 VM_TEST_CASE(Integer) { | 652 ISOLATE_UNIT_TEST_CASE(Integer) { |
| 653 Integer& i = Integer::Handle(); | 653 Integer& i = Integer::Handle(); |
| 654 i = Integer::NewCanonical(String::Handle(String::New("12"))); | 654 i = Integer::NewCanonical(String::Handle(String::New("12"))); |
| 655 EXPECT(i.IsSmi()); | 655 EXPECT(i.IsSmi()); |
| 656 i = Integer::NewCanonical(String::Handle(String::New("-120"))); | 656 i = Integer::NewCanonical(String::Handle(String::New("-120"))); |
| 657 EXPECT(i.IsSmi()); | 657 EXPECT(i.IsSmi()); |
| 658 i = Integer::NewCanonical(String::Handle(String::New("0"))); | 658 i = Integer::NewCanonical(String::Handle(String::New("0"))); |
| 659 EXPECT(i.IsSmi()); | 659 EXPECT(i.IsSmi()); |
| 660 i = Integer::NewCanonical( | 660 i = Integer::NewCanonical( |
| 661 String::Handle(String::New("12345678901234567890"))); | 661 String::Handle(String::New("12345678901234567890"))); |
| 662 EXPECT(i.IsBigint()); | 662 EXPECT(i.IsBigint()); |
| 663 i = Integer::NewCanonical( | 663 i = Integer::NewCanonical( |
| 664 String::Handle(String::New("-12345678901234567890111222"))); | 664 String::Handle(String::New("-12345678901234567890111222"))); |
| 665 EXPECT(i.IsBigint()); | 665 EXPECT(i.IsBigint()); |
| 666 } | 666 } |
| 667 | 667 |
| 668 | 668 |
| 669 VM_TEST_CASE(String) { | 669 ISOLATE_UNIT_TEST_CASE(String) { |
| 670 const char* kHello = "Hello World!"; | 670 const char* kHello = "Hello World!"; |
| 671 int32_t hello_len = strlen(kHello); | 671 int32_t hello_len = strlen(kHello); |
| 672 const String& str = String::Handle(String::New(kHello)); | 672 const String& str = String::Handle(String::New(kHello)); |
| 673 EXPECT(str.IsInstance()); | 673 EXPECT(str.IsInstance()); |
| 674 EXPECT(str.IsString()); | 674 EXPECT(str.IsString()); |
| 675 EXPECT(str.IsOneByteString()); | 675 EXPECT(str.IsOneByteString()); |
| 676 EXPECT(!str.IsTwoByteString()); | 676 EXPECT(!str.IsTwoByteString()); |
| 677 EXPECT(!str.IsNumber()); | 677 EXPECT(!str.IsNumber()); |
| 678 EXPECT_EQ(hello_len, str.Length()); | 678 EXPECT_EQ(hello_len, str.Length()); |
| 679 EXPECT_EQ('H', str.CharAt(0)); | 679 EXPECT_EQ('H', str.CharAt(0)); |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 806 const String& str16 = String::Handle(String::FromUTF32(char32, 3)); | 806 const String& str16 = String::Handle(String::FromUTF32(char32, 3)); |
| 807 EXPECT(!str16.IsOneByteString()); | 807 EXPECT(!str16.IsOneByteString()); |
| 808 EXPECT(str16.IsTwoByteString()); | 808 EXPECT(str16.IsTwoByteString()); |
| 809 EXPECT_EQ(0x0000, str16.CharAt(0)); | 809 EXPECT_EQ(0x0000, str16.CharAt(0)); |
| 810 EXPECT_EQ(0x7FFF, str16.CharAt(1)); | 810 EXPECT_EQ(0x7FFF, str16.CharAt(1)); |
| 811 EXPECT_EQ(0xFFFF, str16.CharAt(2)); | 811 EXPECT_EQ(0xFFFF, str16.CharAt(2)); |
| 812 } | 812 } |
| 813 } | 813 } |
| 814 | 814 |
| 815 | 815 |
| 816 VM_TEST_CASE(StringFormat) { | 816 ISOLATE_UNIT_TEST_CASE(StringFormat) { |
| 817 const char* hello_str = "Hello World!"; | 817 const char* hello_str = "Hello World!"; |
| 818 const String& str = | 818 const String& str = |
| 819 String::Handle(String::NewFormatted("Hello %s!", "World")); | 819 String::Handle(String::NewFormatted("Hello %s!", "World")); |
| 820 EXPECT(str.IsInstance()); | 820 EXPECT(str.IsInstance()); |
| 821 EXPECT(str.IsString()); | 821 EXPECT(str.IsString()); |
| 822 EXPECT(str.IsOneByteString()); | 822 EXPECT(str.IsOneByteString()); |
| 823 EXPECT(!str.IsTwoByteString()); | 823 EXPECT(!str.IsTwoByteString()); |
| 824 EXPECT(!str.IsNumber()); | 824 EXPECT(!str.IsNumber()); |
| 825 EXPECT(str.Equals(hello_str)); | 825 EXPECT(str.Equals(hello_str)); |
| 826 } | 826 } |
| 827 | 827 |
| 828 | 828 |
| 829 VM_TEST_CASE(StringConcat) { | 829 ISOLATE_UNIT_TEST_CASE(StringConcat) { |
| 830 // Create strings from concatenated 1-byte empty strings. | 830 // Create strings from concatenated 1-byte empty strings. |
| 831 { | 831 { |
| 832 const String& empty1 = String::Handle(String::New("")); | 832 const String& empty1 = String::Handle(String::New("")); |
| 833 EXPECT(empty1.IsOneByteString()); | 833 EXPECT(empty1.IsOneByteString()); |
| 834 EXPECT_EQ(0, empty1.Length()); | 834 EXPECT_EQ(0, empty1.Length()); |
| 835 | 835 |
| 836 const String& empty2 = String::Handle(String::New("")); | 836 const String& empty2 = String::Handle(String::New("")); |
| 837 EXPECT(empty2.IsOneByteString()); | 837 EXPECT(empty2.IsOneByteString()); |
| 838 EXPECT_EQ(0, empty2.Length()); | 838 EXPECT_EQ(0, empty2.Length()); |
| 839 | 839 |
| (...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1350 EXPECT_EQ(twostr.Length() * 2 + onestr.Length(), two_one_two_str.Length()); | 1350 EXPECT_EQ(twostr.Length() * 2 + onestr.Length(), two_one_two_str.Length()); |
| 1351 uint16_t two_one_two[] = {0x05E6, 0x05D5, 0x05D5, 0x05D9, 0x05D9, 'o', | 1351 uint16_t two_one_two[] = {0x05E6, 0x05D5, 0x05D5, 0x05D9, 0x05D9, 'o', |
| 1352 'n', 'e', ' ', 'b', 'y', 't', | 1352 'n', 'e', ' ', 'b', 'y', 't', |
| 1353 'e', 0x05E6, 0x05D5, 0x05D5, 0x05D9, 0x05D9}; | 1353 'e', 0x05E6, 0x05D5, 0x05D5, 0x05D9, 0x05D9}; |
| 1354 intptr_t two_one_two_len = sizeof(two_one_two) / sizeof(two_one_two[0]); | 1354 intptr_t two_one_two_len = sizeof(two_one_two) / sizeof(two_one_two[0]); |
| 1355 EXPECT(two_one_two_str.Equals(two_one_two, two_one_two_len)); | 1355 EXPECT(two_one_two_str.Equals(two_one_two, two_one_two_len)); |
| 1356 } | 1356 } |
| 1357 } | 1357 } |
| 1358 | 1358 |
| 1359 | 1359 |
| 1360 VM_TEST_CASE(StringHashConcat) { | 1360 ISOLATE_UNIT_TEST_CASE(StringHashConcat) { |
| 1361 EXPECT_EQ(String::Handle(String::New("onebyte")).Hash(), | 1361 EXPECT_EQ(String::Handle(String::New("onebyte")).Hash(), |
| 1362 String::HashConcat(String::Handle(String::New("one")), | 1362 String::HashConcat(String::Handle(String::New("one")), |
| 1363 String::Handle(String::New("byte")))); | 1363 String::Handle(String::New("byte")))); |
| 1364 uint16_t clef_utf16[] = {0xD834, 0xDD1E}; | 1364 uint16_t clef_utf16[] = {0xD834, 0xDD1E}; |
| 1365 const String& clef = String::Handle(String::FromUTF16(clef_utf16, 2)); | 1365 const String& clef = String::Handle(String::FromUTF16(clef_utf16, 2)); |
| 1366 int32_t clef_utf32[] = {0x1D11E}; | 1366 int32_t clef_utf32[] = {0x1D11E}; |
| 1367 EXPECT(clef.Equals(clef_utf32, 1)); | 1367 EXPECT(clef.Equals(clef_utf32, 1)); |
| 1368 intptr_t hash32 = String::Hash(clef_utf32, 1); | 1368 intptr_t hash32 = String::Hash(clef_utf32, 1); |
| 1369 EXPECT_EQ(hash32, clef.Hash()); | 1369 EXPECT_EQ(hash32, clef.Hash()); |
| 1370 EXPECT_EQ(hash32, String::HashConcat( | 1370 EXPECT_EQ(hash32, String::HashConcat( |
| 1371 String::Handle(String::FromUTF16(clef_utf16, 1)), | 1371 String::Handle(String::FromUTF16(clef_utf16, 1)), |
| 1372 String::Handle(String::FromUTF16(clef_utf16 + 1, 1)))); | 1372 String::Handle(String::FromUTF16(clef_utf16 + 1, 1)))); |
| 1373 } | 1373 } |
| 1374 | 1374 |
| 1375 | 1375 |
| 1376 VM_TEST_CASE(StringSubStringDifferentWidth) { | 1376 ISOLATE_UNIT_TEST_CASE(StringSubStringDifferentWidth) { |
| 1377 // Create 1-byte substring from a 1-byte source string. | 1377 // Create 1-byte substring from a 1-byte source string. |
| 1378 const char* onechars = "\xC3\xB6\xC3\xB1\xC3\xA9"; | 1378 const char* onechars = "\xC3\xB6\xC3\xB1\xC3\xA9"; |
| 1379 | 1379 |
| 1380 const String& onestr = String::Handle(String::New(onechars)); | 1380 const String& onestr = String::Handle(String::New(onechars)); |
| 1381 EXPECT(!onestr.IsNull()); | 1381 EXPECT(!onestr.IsNull()); |
| 1382 EXPECT(onestr.IsOneByteString()); | 1382 EXPECT(onestr.IsOneByteString()); |
| 1383 EXPECT(!onestr.IsTwoByteString()); | 1383 EXPECT(!onestr.IsTwoByteString()); |
| 1384 | 1384 |
| 1385 const String& onesub = String::Handle(String::SubString(onestr, 0)); | 1385 const String& onesub = String::Handle(String::SubString(onestr, 0)); |
| 1386 EXPECT(!onesub.IsNull()); | 1386 EXPECT(!onesub.IsNull()); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1427 EXPECT(foursub2.IsTwoByteString()); | 1427 EXPECT(foursub2.IsTwoByteString()); |
| 1428 EXPECT_EQ(foursub2.Length(), 3); | 1428 EXPECT_EQ(foursub2.Length(), 3); |
| 1429 | 1429 |
| 1430 const String& foursub4 = String::Handle(String::SubString(fourstr, 6)); | 1430 const String& foursub4 = String::Handle(String::SubString(fourstr, 6)); |
| 1431 EXPECT_EQ(foursub4.Length(), 8); | 1431 EXPECT_EQ(foursub4.Length(), 8); |
| 1432 EXPECT(!foursub4.IsNull()); | 1432 EXPECT(!foursub4.IsNull()); |
| 1433 EXPECT(foursub4.IsTwoByteString()); | 1433 EXPECT(foursub4.IsTwoByteString()); |
| 1434 } | 1434 } |
| 1435 | 1435 |
| 1436 | 1436 |
| 1437 VM_TEST_CASE(StringFromUtf8Literal) { | 1437 ISOLATE_UNIT_TEST_CASE(StringFromUtf8Literal) { |
| 1438 // Create a 1-byte string from a UTF-8 encoded string literal. | 1438 // Create a 1-byte string from a UTF-8 encoded string literal. |
| 1439 { | 1439 { |
| 1440 const char* src = | 1440 const char* src = |
| 1441 "\xC2\xA0\xC2\xA1\xC2\xA2\xC2\xA3" | 1441 "\xC2\xA0\xC2\xA1\xC2\xA2\xC2\xA3" |
| 1442 "\xC2\xA4\xC2\xA5\xC2\xA6\xC2\xA7" | 1442 "\xC2\xA4\xC2\xA5\xC2\xA6\xC2\xA7" |
| 1443 "\xC2\xA8\xC2\xA9\xC2\xAA\xC2\xAB" | 1443 "\xC2\xA8\xC2\xA9\xC2\xAA\xC2\xAB" |
| 1444 "\xC2\xAC\xC2\xAD\xC2\xAE\xC2\xAF" | 1444 "\xC2\xAC\xC2\xAD\xC2\xAE\xC2\xAF" |
| 1445 "\xC2\xB0\xC2\xB1\xC2\xB2\xC2\xB3" | 1445 "\xC2\xB0\xC2\xB1\xC2\xB2\xC2\xB3" |
| 1446 "\xC2\xB4\xC2\xB5\xC2\xB6\xC2\xB7" | 1446 "\xC2\xB4\xC2\xB5\xC2\xB6\xC2\xB7" |
| 1447 "\xC2\xB8\xC2\xB9\xC2\xBA\xC2\xBB" | 1447 "\xC2\xB8\xC2\xB9\xC2\xBA\xC2\xBB" |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1587 EXPECT(str.IsTwoByteString()); | 1587 EXPECT(str.IsTwoByteString()); |
| 1588 intptr_t expected_size = sizeof(expected) / sizeof(expected[0]); | 1588 intptr_t expected_size = sizeof(expected) / sizeof(expected[0]); |
| 1589 EXPECT_EQ(expected_size, str.Length()); | 1589 EXPECT_EQ(expected_size, str.Length()); |
| 1590 for (int i = 0; i < str.Length(); ++i) { | 1590 for (int i = 0; i < str.Length(); ++i) { |
| 1591 EXPECT_EQ(expected[i], str.CharAt(i)); | 1591 EXPECT_EQ(expected[i], str.CharAt(i)); |
| 1592 } | 1592 } |
| 1593 } | 1593 } |
| 1594 } | 1594 } |
| 1595 | 1595 |
| 1596 | 1596 |
| 1597 VM_TEST_CASE(StringEqualsUtf8) { | 1597 ISOLATE_UNIT_TEST_CASE(StringEqualsUtf8) { |
| 1598 const char* onesrc = "abc"; | 1598 const char* onesrc = "abc"; |
| 1599 const String& onestr = String::Handle(String::New(onesrc)); | 1599 const String& onestr = String::Handle(String::New(onesrc)); |
| 1600 EXPECT(onestr.IsOneByteString()); | 1600 EXPECT(onestr.IsOneByteString()); |
| 1601 EXPECT(!onestr.Equals("")); | 1601 EXPECT(!onestr.Equals("")); |
| 1602 EXPECT(!onestr.Equals("a")); | 1602 EXPECT(!onestr.Equals("a")); |
| 1603 EXPECT(!onestr.Equals("ab")); | 1603 EXPECT(!onestr.Equals("ab")); |
| 1604 EXPECT(onestr.Equals("abc")); | 1604 EXPECT(onestr.Equals("abc")); |
| 1605 EXPECT(!onestr.Equals("abcd")); | 1605 EXPECT(!onestr.Equals("abcd")); |
| 1606 | 1606 |
| 1607 const char* twosrc = "\xD7\x90\xD7\x91\xD7\x92"; | 1607 const char* twosrc = "\xD7\x90\xD7\x91\xD7\x92"; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1619 EXPECT(!fourstr.Equals("")); | 1619 EXPECT(!fourstr.Equals("")); |
| 1620 EXPECT(!fourstr.Equals("\xF0\x90\x8E\xA0")); | 1620 EXPECT(!fourstr.Equals("\xF0\x90\x8E\xA0")); |
| 1621 EXPECT(!fourstr.Equals("\xF0\x90\x8E\xA0\xF0\x90\x8E\xA1")); | 1621 EXPECT(!fourstr.Equals("\xF0\x90\x8E\xA0\xF0\x90\x8E\xA1")); |
| 1622 EXPECT(fourstr.Equals("\xF0\x90\x8E\xA0\xF0\x90\x8E\xA1\xF0\x90\x8E\xA2")); | 1622 EXPECT(fourstr.Equals("\xF0\x90\x8E\xA0\xF0\x90\x8E\xA1\xF0\x90\x8E\xA2")); |
| 1623 EXPECT( | 1623 EXPECT( |
| 1624 !fourstr.Equals("\xF0\x90\x8E\xA0\xF0\x90\x8E\xA1" | 1624 !fourstr.Equals("\xF0\x90\x8E\xA0\xF0\x90\x8E\xA1" |
| 1625 "\xF0\x90\x8E\xA2\xF0\x90\x8E\xA3")); | 1625 "\xF0\x90\x8E\xA2\xF0\x90\x8E\xA3")); |
| 1626 } | 1626 } |
| 1627 | 1627 |
| 1628 | 1628 |
| 1629 VM_TEST_CASE(StringEqualsUTF32) { | 1629 ISOLATE_UNIT_TEST_CASE(StringEqualsUTF32) { |
| 1630 const String& empty = String::Handle(String::New("")); | 1630 const String& empty = String::Handle(String::New("")); |
| 1631 const String& t_str = String::Handle(String::New("t")); | 1631 const String& t_str = String::Handle(String::New("t")); |
| 1632 const String& th_str = String::Handle(String::New("th")); | 1632 const String& th_str = String::Handle(String::New("th")); |
| 1633 const int32_t chars[] = {'t', 'h', 'i', 's'}; | 1633 const int32_t chars[] = {'t', 'h', 'i', 's'}; |
| 1634 EXPECT(!empty.Equals(chars, -1)); | 1634 EXPECT(!empty.Equals(chars, -1)); |
| 1635 EXPECT(empty.Equals(chars, 0)); | 1635 EXPECT(empty.Equals(chars, 0)); |
| 1636 EXPECT(!empty.Equals(chars, 1)); | 1636 EXPECT(!empty.Equals(chars, 1)); |
| 1637 EXPECT(!t_str.Equals(chars, 0)); | 1637 EXPECT(!t_str.Equals(chars, 0)); |
| 1638 EXPECT(t_str.Equals(chars, 1)); | 1638 EXPECT(t_str.Equals(chars, 1)); |
| 1639 EXPECT(!t_str.Equals(chars, 2)); | 1639 EXPECT(!t_str.Equals(chars, 2)); |
| 1640 EXPECT(!th_str.Equals(chars, 1)); | 1640 EXPECT(!th_str.Equals(chars, 1)); |
| 1641 EXPECT(th_str.Equals(chars, 2)); | 1641 EXPECT(th_str.Equals(chars, 2)); |
| 1642 EXPECT(!th_str.Equals(chars, 3)); | 1642 EXPECT(!th_str.Equals(chars, 3)); |
| 1643 } | 1643 } |
| 1644 | 1644 |
| 1645 | 1645 |
| 1646 VM_TEST_CASE(ExternalOneByteString) { | 1646 ISOLATE_UNIT_TEST_CASE(ExternalOneByteString) { |
| 1647 uint8_t characters[] = {0xF6, 0xF1, 0xE9}; | 1647 uint8_t characters[] = {0xF6, 0xF1, 0xE9}; |
| 1648 intptr_t len = ARRAY_SIZE(characters); | 1648 intptr_t len = ARRAY_SIZE(characters); |
| 1649 | 1649 |
| 1650 const String& str = String::Handle( | 1650 const String& str = String::Handle( |
| 1651 ExternalOneByteString::New(characters, len, NULL, NULL, Heap::kNew)); | 1651 ExternalOneByteString::New(characters, len, NULL, NULL, Heap::kNew)); |
| 1652 EXPECT(!str.IsOneByteString()); | 1652 EXPECT(!str.IsOneByteString()); |
| 1653 EXPECT(str.IsExternalOneByteString()); | 1653 EXPECT(str.IsExternalOneByteString()); |
| 1654 EXPECT_EQ(str.Length(), len); | 1654 EXPECT_EQ(str.Length(), len); |
| 1655 EXPECT(str.Equals("\xC3\xB6\xC3\xB1\xC3\xA9")); | 1655 EXPECT(str.Equals("\xC3\xB6\xC3\xB1\xC3\xA9")); |
| 1656 | 1656 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1667 EXPECT(concat.Equals("\xC3\xB6\xC3\xB1\xC3\xA9\xC3\xB6\xC3\xB1\xC3\xA9")); | 1667 EXPECT(concat.Equals("\xC3\xB6\xC3\xB1\xC3\xA9\xC3\xB6\xC3\xB1\xC3\xA9")); |
| 1668 | 1668 |
| 1669 const String& substr = String::Handle(String::SubString(str, 1, 1)); | 1669 const String& substr = String::Handle(String::SubString(str, 1, 1)); |
| 1670 EXPECT(!substr.IsExternalOneByteString()); | 1670 EXPECT(!substr.IsExternalOneByteString()); |
| 1671 EXPECT(substr.IsOneByteString()); | 1671 EXPECT(substr.IsOneByteString()); |
| 1672 EXPECT_EQ(1, substr.Length()); | 1672 EXPECT_EQ(1, substr.Length()); |
| 1673 EXPECT(substr.Equals("\xC3\xB1")); | 1673 EXPECT(substr.Equals("\xC3\xB1")); |
| 1674 } | 1674 } |
| 1675 | 1675 |
| 1676 | 1676 |
| 1677 VM_TEST_CASE(EscapeSpecialCharactersOneByteString) { | 1677 ISOLATE_UNIT_TEST_CASE(EscapeSpecialCharactersOneByteString) { |
| 1678 uint8_t characters[] = {'a', '\n', '\f', '\b', '\t', | 1678 uint8_t characters[] = {'a', '\n', '\f', '\b', '\t', |
| 1679 '\v', '\r', '\\', '$', 'z'}; | 1679 '\v', '\r', '\\', '$', 'z'}; |
| 1680 intptr_t len = ARRAY_SIZE(characters); | 1680 intptr_t len = ARRAY_SIZE(characters); |
| 1681 | 1681 |
| 1682 const String& str = | 1682 const String& str = |
| 1683 String::Handle(OneByteString::New(characters, len, Heap::kNew)); | 1683 String::Handle(OneByteString::New(characters, len, Heap::kNew)); |
| 1684 EXPECT(str.IsOneByteString()); | 1684 EXPECT(str.IsOneByteString()); |
| 1685 EXPECT_EQ(str.Length(), len); | 1685 EXPECT_EQ(str.Length(), len); |
| 1686 EXPECT(str.Equals("a\n\f\b\t\v\r\\$z")); | 1686 EXPECT(str.Equals("a\n\f\b\t\v\r\\$z")); |
| 1687 const String& escaped_str = | 1687 const String& escaped_str = |
| 1688 String::Handle(String::EscapeSpecialCharacters(str)); | 1688 String::Handle(String::EscapeSpecialCharacters(str)); |
| 1689 EXPECT(escaped_str.Equals("a\\n\\f\\b\\t\\v\\r\\\\\\$z")); | 1689 EXPECT(escaped_str.Equals("a\\n\\f\\b\\t\\v\\r\\\\\\$z")); |
| 1690 | 1690 |
| 1691 const String& escaped_empty_str = | 1691 const String& escaped_empty_str = |
| 1692 String::Handle(String::EscapeSpecialCharacters(Symbols::Empty())); | 1692 String::Handle(String::EscapeSpecialCharacters(Symbols::Empty())); |
| 1693 EXPECT_EQ(escaped_empty_str.Length(), 0); | 1693 EXPECT_EQ(escaped_empty_str.Length(), 0); |
| 1694 } | 1694 } |
| 1695 | 1695 |
| 1696 | 1696 |
| 1697 VM_TEST_CASE(EscapeSpecialCharactersExternalOneByteString) { | 1697 ISOLATE_UNIT_TEST_CASE(EscapeSpecialCharactersExternalOneByteString) { |
| 1698 uint8_t characters[] = {'a', '\n', '\f', '\b', '\t', | 1698 uint8_t characters[] = {'a', '\n', '\f', '\b', '\t', |
| 1699 '\v', '\r', '\\', '$', 'z'}; | 1699 '\v', '\r', '\\', '$', 'z'}; |
| 1700 intptr_t len = ARRAY_SIZE(characters); | 1700 intptr_t len = ARRAY_SIZE(characters); |
| 1701 | 1701 |
| 1702 const String& str = String::Handle( | 1702 const String& str = String::Handle( |
| 1703 ExternalOneByteString::New(characters, len, NULL, NULL, Heap::kNew)); | 1703 ExternalOneByteString::New(characters, len, NULL, NULL, Heap::kNew)); |
| 1704 EXPECT(!str.IsOneByteString()); | 1704 EXPECT(!str.IsOneByteString()); |
| 1705 EXPECT(str.IsExternalOneByteString()); | 1705 EXPECT(str.IsExternalOneByteString()); |
| 1706 EXPECT_EQ(str.Length(), len); | 1706 EXPECT_EQ(str.Length(), len); |
| 1707 EXPECT(str.Equals("a\n\f\b\t\v\r\\$z")); | 1707 EXPECT(str.Equals("a\n\f\b\t\v\r\\$z")); |
| 1708 const String& escaped_str = | 1708 const String& escaped_str = |
| 1709 String::Handle(String::EscapeSpecialCharacters(str)); | 1709 String::Handle(String::EscapeSpecialCharacters(str)); |
| 1710 EXPECT(escaped_str.Equals("a\\n\\f\\b\\t\\v\\r\\\\\\$z")); | 1710 EXPECT(escaped_str.Equals("a\\n\\f\\b\\t\\v\\r\\\\\\$z")); |
| 1711 | 1711 |
| 1712 const String& empty_str = String::Handle( | 1712 const String& empty_str = String::Handle( |
| 1713 ExternalOneByteString::New(characters, 0, NULL, NULL, Heap::kNew)); | 1713 ExternalOneByteString::New(characters, 0, NULL, NULL, Heap::kNew)); |
| 1714 const String& escaped_empty_str = | 1714 const String& escaped_empty_str = |
| 1715 String::Handle(String::EscapeSpecialCharacters(empty_str)); | 1715 String::Handle(String::EscapeSpecialCharacters(empty_str)); |
| 1716 EXPECT_EQ(empty_str.Length(), 0); | 1716 EXPECT_EQ(empty_str.Length(), 0); |
| 1717 EXPECT_EQ(escaped_empty_str.Length(), 0); | 1717 EXPECT_EQ(escaped_empty_str.Length(), 0); |
| 1718 } | 1718 } |
| 1719 | 1719 |
| 1720 VM_TEST_CASE(EscapeSpecialCharactersTwoByteString) { | 1720 ISOLATE_UNIT_TEST_CASE(EscapeSpecialCharactersTwoByteString) { |
| 1721 uint16_t characters[] = {'a', '\n', '\f', '\b', '\t', | 1721 uint16_t characters[] = {'a', '\n', '\f', '\b', '\t', |
| 1722 '\v', '\r', '\\', '$', 'z'}; | 1722 '\v', '\r', '\\', '$', 'z'}; |
| 1723 intptr_t len = ARRAY_SIZE(characters); | 1723 intptr_t len = ARRAY_SIZE(characters); |
| 1724 | 1724 |
| 1725 const String& str = | 1725 const String& str = |
| 1726 String::Handle(TwoByteString::New(characters, len, Heap::kNew)); | 1726 String::Handle(TwoByteString::New(characters, len, Heap::kNew)); |
| 1727 EXPECT(str.IsTwoByteString()); | 1727 EXPECT(str.IsTwoByteString()); |
| 1728 EXPECT_EQ(str.Length(), len); | 1728 EXPECT_EQ(str.Length(), len); |
| 1729 EXPECT(str.Equals("a\n\f\b\t\v\r\\$z")); | 1729 EXPECT(str.Equals("a\n\f\b\t\v\r\\$z")); |
| 1730 const String& escaped_str = | 1730 const String& escaped_str = |
| 1731 String::Handle(String::EscapeSpecialCharacters(str)); | 1731 String::Handle(String::EscapeSpecialCharacters(str)); |
| 1732 EXPECT(escaped_str.Equals("a\\n\\f\\b\\t\\v\\r\\\\\\$z")); | 1732 EXPECT(escaped_str.Equals("a\\n\\f\\b\\t\\v\\r\\\\\\$z")); |
| 1733 | 1733 |
| 1734 const String& empty_str = | 1734 const String& empty_str = |
| 1735 String::Handle(TwoByteString::New(static_cast<intptr_t>(0), Heap::kNew)); | 1735 String::Handle(TwoByteString::New(static_cast<intptr_t>(0), Heap::kNew)); |
| 1736 const String& escaped_empty_str = | 1736 const String& escaped_empty_str = |
| 1737 String::Handle(String::EscapeSpecialCharacters(empty_str)); | 1737 String::Handle(String::EscapeSpecialCharacters(empty_str)); |
| 1738 EXPECT_EQ(empty_str.Length(), 0); | 1738 EXPECT_EQ(empty_str.Length(), 0); |
| 1739 EXPECT_EQ(escaped_empty_str.Length(), 0); | 1739 EXPECT_EQ(escaped_empty_str.Length(), 0); |
| 1740 } | 1740 } |
| 1741 | 1741 |
| 1742 | 1742 |
| 1743 VM_TEST_CASE(EscapeSpecialCharactersExternalTwoByteString) { | 1743 ISOLATE_UNIT_TEST_CASE(EscapeSpecialCharactersExternalTwoByteString) { |
| 1744 uint16_t characters[] = {'a', '\n', '\f', '\b', '\t', | 1744 uint16_t characters[] = {'a', '\n', '\f', '\b', '\t', |
| 1745 '\v', '\r', '\\', '$', 'z'}; | 1745 '\v', '\r', '\\', '$', 'z'}; |
| 1746 intptr_t len = ARRAY_SIZE(characters); | 1746 intptr_t len = ARRAY_SIZE(characters); |
| 1747 | 1747 |
| 1748 const String& str = String::Handle( | 1748 const String& str = String::Handle( |
| 1749 ExternalTwoByteString::New(characters, len, NULL, NULL, Heap::kNew)); | 1749 ExternalTwoByteString::New(characters, len, NULL, NULL, Heap::kNew)); |
| 1750 EXPECT(str.IsExternalTwoByteString()); | 1750 EXPECT(str.IsExternalTwoByteString()); |
| 1751 EXPECT_EQ(str.Length(), len); | 1751 EXPECT_EQ(str.Length(), len); |
| 1752 EXPECT(str.Equals("a\n\f\b\t\v\r\\$z")); | 1752 EXPECT(str.Equals("a\n\f\b\t\v\r\\$z")); |
| 1753 const String& escaped_str = | 1753 const String& escaped_str = |
| 1754 String::Handle(String::EscapeSpecialCharacters(str)); | 1754 String::Handle(String::EscapeSpecialCharacters(str)); |
| 1755 EXPECT(escaped_str.Equals("a\\n\\f\\b\\t\\v\\r\\\\\\$z")); | 1755 EXPECT(escaped_str.Equals("a\\n\\f\\b\\t\\v\\r\\\\\\$z")); |
| 1756 | 1756 |
| 1757 const String& empty_str = String::Handle( | 1757 const String& empty_str = String::Handle( |
| 1758 ExternalTwoByteString::New(characters, 0, NULL, NULL, Heap::kNew)); | 1758 ExternalTwoByteString::New(characters, 0, NULL, NULL, Heap::kNew)); |
| 1759 const String& escaped_empty_str = | 1759 const String& escaped_empty_str = |
| 1760 String::Handle(String::EscapeSpecialCharacters(empty_str)); | 1760 String::Handle(String::EscapeSpecialCharacters(empty_str)); |
| 1761 EXPECT_EQ(empty_str.Length(), 0); | 1761 EXPECT_EQ(empty_str.Length(), 0); |
| 1762 EXPECT_EQ(escaped_empty_str.Length(), 0); | 1762 EXPECT_EQ(escaped_empty_str.Length(), 0); |
| 1763 } | 1763 } |
| 1764 | 1764 |
| 1765 | 1765 |
| 1766 VM_TEST_CASE(ExternalTwoByteString) { | 1766 ISOLATE_UNIT_TEST_CASE(ExternalTwoByteString) { |
| 1767 uint16_t characters[] = {0x1E6B, 0x1E85, 0x1E53}; | 1767 uint16_t characters[] = {0x1E6B, 0x1E85, 0x1E53}; |
| 1768 intptr_t len = ARRAY_SIZE(characters); | 1768 intptr_t len = ARRAY_SIZE(characters); |
| 1769 | 1769 |
| 1770 const String& str = String::Handle( | 1770 const String& str = String::Handle( |
| 1771 ExternalTwoByteString::New(characters, len, NULL, NULL, Heap::kNew)); | 1771 ExternalTwoByteString::New(characters, len, NULL, NULL, Heap::kNew)); |
| 1772 EXPECT(!str.IsTwoByteString()); | 1772 EXPECT(!str.IsTwoByteString()); |
| 1773 EXPECT(str.IsExternalTwoByteString()); | 1773 EXPECT(str.IsExternalTwoByteString()); |
| 1774 EXPECT_EQ(str.Length(), len); | 1774 EXPECT_EQ(str.Length(), len); |
| 1775 EXPECT(str.Equals("\xE1\xB9\xAB\xE1\xBA\x85\xE1\xB9\x93")); | 1775 EXPECT(str.Equals("\xE1\xB9\xAB\xE1\xBA\x85\xE1\xB9\x93")); |
| 1776 | 1776 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1789 "\xE1\xB9\xAB\xE1\xBA\x85\xE1\xB9\x93")); | 1789 "\xE1\xB9\xAB\xE1\xBA\x85\xE1\xB9\x93")); |
| 1790 | 1790 |
| 1791 const String& substr = String::Handle(String::SubString(str, 1, 1)); | 1791 const String& substr = String::Handle(String::SubString(str, 1, 1)); |
| 1792 EXPECT(!substr.IsExternalTwoByteString()); | 1792 EXPECT(!substr.IsExternalTwoByteString()); |
| 1793 EXPECT(substr.IsTwoByteString()); | 1793 EXPECT(substr.IsTwoByteString()); |
| 1794 EXPECT_EQ(1, substr.Length()); | 1794 EXPECT_EQ(1, substr.Length()); |
| 1795 EXPECT(substr.Equals("\xE1\xBA\x85")); | 1795 EXPECT(substr.Equals("\xE1\xBA\x85")); |
| 1796 } | 1796 } |
| 1797 | 1797 |
| 1798 | 1798 |
| 1799 VM_TEST_CASE(Symbol) { | 1799 ISOLATE_UNIT_TEST_CASE(Symbol) { |
| 1800 const String& one = String::Handle(Symbols::New(thread, "Eins")); | 1800 const String& one = String::Handle(Symbols::New(thread, "Eins")); |
| 1801 EXPECT(one.IsSymbol()); | 1801 EXPECT(one.IsSymbol()); |
| 1802 const String& two = String::Handle(Symbols::New(thread, "Zwei")); | 1802 const String& two = String::Handle(Symbols::New(thread, "Zwei")); |
| 1803 const String& three = String::Handle(Symbols::New(thread, "Drei")); | 1803 const String& three = String::Handle(Symbols::New(thread, "Drei")); |
| 1804 const String& four = String::Handle(Symbols::New(thread, "Vier")); | 1804 const String& four = String::Handle(Symbols::New(thread, "Vier")); |
| 1805 const String& five = String::Handle(Symbols::New(thread, "Fuenf")); | 1805 const String& five = String::Handle(Symbols::New(thread, "Fuenf")); |
| 1806 const String& six = String::Handle(Symbols::New(thread, "Sechs")); | 1806 const String& six = String::Handle(Symbols::New(thread, "Sechs")); |
| 1807 const String& seven = String::Handle(Symbols::New(thread, "Sieben")); | 1807 const String& seven = String::Handle(Symbols::New(thread, "Sieben")); |
| 1808 const String& eight = String::Handle(Symbols::New(thread, "Acht")); | 1808 const String& eight = String::Handle(Symbols::New(thread, "Acht")); |
| 1809 const String& nine = String::Handle(Symbols::New(thread, "Neun")); | 1809 const String& nine = String::Handle(Symbols::New(thread, "Neun")); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1851 String& elf1 = String::Handle(Symbols::FromUTF16(thread, char16, 3)); | 1851 String& elf1 = String::Handle(Symbols::FromUTF16(thread, char16, 3)); |
| 1852 int32_t char32[] = {'E', 'l', 'f'}; | 1852 int32_t char32[] = {'E', 'l', 'f'}; |
| 1853 String& elf2 = String::Handle(Symbols::FromUTF32(thread, char32, 3)); | 1853 String& elf2 = String::Handle(Symbols::FromUTF32(thread, char32, 3)); |
| 1854 EXPECT(elf1.IsSymbol()); | 1854 EXPECT(elf1.IsSymbol()); |
| 1855 EXPECT(elf2.IsSymbol()); | 1855 EXPECT(elf2.IsSymbol()); |
| 1856 EXPECT_EQ(elf1.raw(), Symbols::New(thread, "Elf")); | 1856 EXPECT_EQ(elf1.raw(), Symbols::New(thread, "Elf")); |
| 1857 EXPECT_EQ(elf2.raw(), Symbols::New(thread, "Elf")); | 1857 EXPECT_EQ(elf2.raw(), Symbols::New(thread, "Elf")); |
| 1858 } | 1858 } |
| 1859 | 1859 |
| 1860 | 1860 |
| 1861 VM_TEST_CASE(SymbolUnicode) { | 1861 ISOLATE_UNIT_TEST_CASE(SymbolUnicode) { |
| 1862 uint16_t monkey_utf16[] = {0xd83d, 0xdc35}; // Unicode Monkey Face. | 1862 uint16_t monkey_utf16[] = {0xd83d, 0xdc35}; // Unicode Monkey Face. |
| 1863 String& monkey = String::Handle(Symbols::FromUTF16(thread, monkey_utf16, 2)); | 1863 String& monkey = String::Handle(Symbols::FromUTF16(thread, monkey_utf16, 2)); |
| 1864 EXPECT(monkey.IsSymbol()); | 1864 EXPECT(monkey.IsSymbol()); |
| 1865 const char monkey_utf8[] = {'\xf0', '\x9f', '\x90', '\xb5', 0}; | 1865 const char monkey_utf8[] = {'\xf0', '\x9f', '\x90', '\xb5', 0}; |
| 1866 EXPECT_EQ(monkey.raw(), Symbols::New(thread, monkey_utf8)); | 1866 EXPECT_EQ(monkey.raw(), Symbols::New(thread, monkey_utf8)); |
| 1867 | 1867 |
| 1868 int32_t kMonkeyFace = 0x1f435; | 1868 int32_t kMonkeyFace = 0x1f435; |
| 1869 String& monkey2 = String::Handle(Symbols::FromCharCode(thread, kMonkeyFace)); | 1869 String& monkey2 = String::Handle(Symbols::FromCharCode(thread, kMonkeyFace)); |
| 1870 EXPECT_EQ(monkey.raw(), monkey2.raw()); | 1870 EXPECT_EQ(monkey.raw(), monkey2.raw()); |
| 1871 | 1871 |
| 1872 // Unicode cat face with tears of joy. | 1872 // Unicode cat face with tears of joy. |
| 1873 int32_t kCatFaceWithTearsOfJoy = 0x1f639; | 1873 int32_t kCatFaceWithTearsOfJoy = 0x1f639; |
| 1874 String& cat = | 1874 String& cat = |
| 1875 String::Handle(Symbols::FromCharCode(thread, kCatFaceWithTearsOfJoy)); | 1875 String::Handle(Symbols::FromCharCode(thread, kCatFaceWithTearsOfJoy)); |
| 1876 | 1876 |
| 1877 uint16_t cat_utf16[] = {0xd83d, 0xde39}; | 1877 uint16_t cat_utf16[] = {0xd83d, 0xde39}; |
| 1878 String& cat2 = String::Handle(Symbols::FromUTF16(thread, cat_utf16, 2)); | 1878 String& cat2 = String::Handle(Symbols::FromUTF16(thread, cat_utf16, 2)); |
| 1879 EXPECT(cat2.IsSymbol()); | 1879 EXPECT(cat2.IsSymbol()); |
| 1880 EXPECT_EQ(cat2.raw(), cat.raw()); | 1880 EXPECT_EQ(cat2.raw(), cat.raw()); |
| 1881 } | 1881 } |
| 1882 | 1882 |
| 1883 | 1883 |
| 1884 VM_TEST_CASE(Bool) { | 1884 ISOLATE_UNIT_TEST_CASE(Bool) { |
| 1885 EXPECT(Bool::True().value()); | 1885 EXPECT(Bool::True().value()); |
| 1886 EXPECT(!Bool::False().value()); | 1886 EXPECT(!Bool::False().value()); |
| 1887 } | 1887 } |
| 1888 | 1888 |
| 1889 | 1889 |
| 1890 VM_TEST_CASE(Array) { | 1890 ISOLATE_UNIT_TEST_CASE(Array) { |
| 1891 const int kArrayLen = 5; | 1891 const int kArrayLen = 5; |
| 1892 const Array& array = Array::Handle(Array::New(kArrayLen)); | 1892 const Array& array = Array::Handle(Array::New(kArrayLen)); |
| 1893 EXPECT_EQ(kArrayLen, array.Length()); | 1893 EXPECT_EQ(kArrayLen, array.Length()); |
| 1894 Object& element = Object::Handle(array.At(0)); | 1894 Object& element = Object::Handle(array.At(0)); |
| 1895 EXPECT(element.IsNull()); | 1895 EXPECT(element.IsNull()); |
| 1896 element = array.At(kArrayLen - 1); | 1896 element = array.At(kArrayLen - 1); |
| 1897 EXPECT(element.IsNull()); | 1897 EXPECT(element.IsNull()); |
| 1898 array.SetAt(0, array); | 1898 array.SetAt(0, array); |
| 1899 array.SetAt(2, array); | 1899 array.SetAt(2, array); |
| 1900 element = array.At(0); | 1900 element = array.At(0); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2035 if (Dart_IsError(result)) { | 2035 if (Dart_IsError(result)) { |
| 2036 EXPECT_ERROR(result, "Out of Memory"); | 2036 EXPECT_ERROR(result, "Out of Memory"); |
| 2037 } else { | 2037 } else { |
| 2038 intptr_t actual = 0; | 2038 intptr_t actual = 0; |
| 2039 EXPECT_VALID(Dart_ListLength(result, &actual)); | 2039 EXPECT_VALID(Dart_ListLength(result, &actual)); |
| 2040 EXPECT_EQ(max_elements, actual); | 2040 EXPECT_EQ(max_elements, actual); |
| 2041 } | 2041 } |
| 2042 } | 2042 } |
| 2043 | 2043 |
| 2044 | 2044 |
| 2045 VM_TEST_CASE(StringCodePointIterator) { | 2045 ISOLATE_UNIT_TEST_CASE(StringCodePointIterator) { |
| 2046 const String& str0 = String::Handle(String::New("")); | 2046 const String& str0 = String::Handle(String::New("")); |
| 2047 String::CodePointIterator it0(str0); | 2047 String::CodePointIterator it0(str0); |
| 2048 EXPECT(!it0.Next()); | 2048 EXPECT(!it0.Next()); |
| 2049 | 2049 |
| 2050 const String& str1 = String::Handle(String::New(" \xc3\xa7 ")); | 2050 const String& str1 = String::Handle(String::New(" \xc3\xa7 ")); |
| 2051 String::CodePointIterator it1(str1); | 2051 String::CodePointIterator it1(str1); |
| 2052 EXPECT(it1.Next()); | 2052 EXPECT(it1.Next()); |
| 2053 EXPECT_EQ(' ', it1.Current()); | 2053 EXPECT_EQ(' ', it1.Current()); |
| 2054 EXPECT(it1.Next()); | 2054 EXPECT(it1.Next()); |
| 2055 EXPECT_EQ(0xE7, it1.Current()); | 2055 EXPECT_EQ(0xE7, it1.Current()); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2092 EXPECT(it3.Next()); | 2092 EXPECT(it3.Next()); |
| 2093 EXPECT_EQ(0x1D461, it3.Current()); | 2093 EXPECT_EQ(0x1D461, it3.Current()); |
| 2094 EXPECT(it3.Next()); | 2094 EXPECT(it3.Next()); |
| 2095 EXPECT_EQ(0x1D462, it3.Current()); | 2095 EXPECT_EQ(0x1D462, it3.Current()); |
| 2096 EXPECT(it3.Next()); | 2096 EXPECT(it3.Next()); |
| 2097 EXPECT_EQ(0x1D463, it3.Current()); | 2097 EXPECT_EQ(0x1D463, it3.Current()); |
| 2098 EXPECT(!it3.Next()); | 2098 EXPECT(!it3.Next()); |
| 2099 } | 2099 } |
| 2100 | 2100 |
| 2101 | 2101 |
| 2102 VM_TEST_CASE(StringCodePointIteratorRange) { | 2102 ISOLATE_UNIT_TEST_CASE(StringCodePointIteratorRange) { |
| 2103 const String& str = String::Handle(String::New("foo bar baz")); | 2103 const String& str = String::Handle(String::New("foo bar baz")); |
| 2104 | 2104 |
| 2105 String::CodePointIterator it0(str, 3, 0); | 2105 String::CodePointIterator it0(str, 3, 0); |
| 2106 EXPECT(!it0.Next()); | 2106 EXPECT(!it0.Next()); |
| 2107 | 2107 |
| 2108 String::CodePointIterator it1(str, 4, 3); | 2108 String::CodePointIterator it1(str, 4, 3); |
| 2109 EXPECT(it1.Next()); | 2109 EXPECT(it1.Next()); |
| 2110 EXPECT_EQ('b', it1.Current()); | 2110 EXPECT_EQ('b', it1.Current()); |
| 2111 EXPECT(it1.Next()); | 2111 EXPECT(it1.Next()); |
| 2112 EXPECT_EQ('a', it1.Current()); | 2112 EXPECT_EQ('a', it1.Current()); |
| 2113 EXPECT(it1.Next()); | 2113 EXPECT(it1.Next()); |
| 2114 EXPECT_EQ('r', it1.Current()); | 2114 EXPECT_EQ('r', it1.Current()); |
| 2115 EXPECT(!it1.Next()); | 2115 EXPECT(!it1.Next()); |
| 2116 } | 2116 } |
| 2117 | 2117 |
| 2118 | 2118 |
| 2119 VM_TEST_CASE(GrowableObjectArray) { | 2119 ISOLATE_UNIT_TEST_CASE(GrowableObjectArray) { |
| 2120 const int kArrayLen = 5; | 2120 const int kArrayLen = 5; |
| 2121 Smi& value = Smi::Handle(); | 2121 Smi& value = Smi::Handle(); |
| 2122 Smi& expected_value = Smi::Handle(); | 2122 Smi& expected_value = Smi::Handle(); |
| 2123 GrowableObjectArray& array = GrowableObjectArray::Handle(); | 2123 GrowableObjectArray& array = GrowableObjectArray::Handle(); |
| 2124 | 2124 |
| 2125 // Test basic growing functionality. | 2125 // Test basic growing functionality. |
| 2126 array = GrowableObjectArray::New(kArrayLen); | 2126 array = GrowableObjectArray::New(kArrayLen); |
| 2127 EXPECT_EQ(kArrayLen, array.Capacity()); | 2127 EXPECT_EQ(kArrayLen, array.Capacity()); |
| 2128 EXPECT_EQ(0, array.Length()); | 2128 EXPECT_EQ(0, array.Length()); |
| 2129 for (intptr_t i = 0; i < 10; i++) { | 2129 for (intptr_t i = 0; i < 10; i++) { |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2231 new_array = Array::MakeArray(array); | 2231 new_array = Array::MakeArray(array); |
| 2232 EXPECT_EQ(1, new_array.Length()); | 2232 EXPECT_EQ(1, new_array.Length()); |
| 2233 heap->CollectAllGarbage(); | 2233 heap->CollectAllGarbage(); |
| 2234 intptr_t capacity_after = heap->CapacityInWords(Heap::kOld); | 2234 intptr_t capacity_after = heap->CapacityInWords(Heap::kOld); |
| 2235 // Page should shrink. | 2235 // Page should shrink. |
| 2236 EXPECT_LT(capacity_after, capacity_before); | 2236 EXPECT_LT(capacity_after, capacity_before); |
| 2237 EXPECT_EQ(1, new_array.Length()); | 2237 EXPECT_EQ(1, new_array.Length()); |
| 2238 } | 2238 } |
| 2239 | 2239 |
| 2240 | 2240 |
| 2241 VM_TEST_CASE(InternalTypedData) { | 2241 ISOLATE_UNIT_TEST_CASE(InternalTypedData) { |
| 2242 uint8_t data[] = {253, 254, 255, 0, 1, 2, 3, 4}; | 2242 uint8_t data[] = {253, 254, 255, 0, 1, 2, 3, 4}; |
| 2243 intptr_t data_length = ARRAY_SIZE(data); | 2243 intptr_t data_length = ARRAY_SIZE(data); |
| 2244 | 2244 |
| 2245 const TypedData& int8_array = | 2245 const TypedData& int8_array = |
| 2246 TypedData::Handle(TypedData::New(kTypedDataInt8ArrayCid, data_length)); | 2246 TypedData::Handle(TypedData::New(kTypedDataInt8ArrayCid, data_length)); |
| 2247 EXPECT(!int8_array.IsNull()); | 2247 EXPECT(!int8_array.IsNull()); |
| 2248 EXPECT_EQ(data_length, int8_array.Length()); | 2248 EXPECT_EQ(data_length, int8_array.Length()); |
| 2249 for (intptr_t i = 0; i < data_length; ++i) { | 2249 for (intptr_t i = 0; i < data_length; ++i) { |
| 2250 int8_array.SetInt8(i, data[i]); | 2250 int8_array.SetInt8(i, data[i]); |
| 2251 } | 2251 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2287 } | 2287 } |
| 2288 for (intptr_t i = 0; i < data_length; ++i) { | 2288 for (intptr_t i = 0; i < data_length; ++i) { |
| 2289 int8_array.SetInt8(i, 123 + i); | 2289 int8_array.SetInt8(i, 123 + i); |
| 2290 } | 2290 } |
| 2291 for (intptr_t i = 0; i < data_length; ++i) { | 2291 for (intptr_t i = 0; i < data_length; ++i) { |
| 2292 EXPECT(int8_array.GetInt8(i) != int8_array2.GetInt8(i)); | 2292 EXPECT(int8_array.GetInt8(i) != int8_array2.GetInt8(i)); |
| 2293 } | 2293 } |
| 2294 } | 2294 } |
| 2295 | 2295 |
| 2296 | 2296 |
| 2297 VM_TEST_CASE(ExternalTypedData) { | 2297 ISOLATE_UNIT_TEST_CASE(ExternalTypedData) { |
| 2298 uint8_t data[] = {253, 254, 255, 0, 1, 2, 3, 4}; | 2298 uint8_t data[] = {253, 254, 255, 0, 1, 2, 3, 4}; |
| 2299 intptr_t data_length = ARRAY_SIZE(data); | 2299 intptr_t data_length = ARRAY_SIZE(data); |
| 2300 | 2300 |
| 2301 const ExternalTypedData& int8_array = | 2301 const ExternalTypedData& int8_array = |
| 2302 ExternalTypedData::Handle(ExternalTypedData::New( | 2302 ExternalTypedData::Handle(ExternalTypedData::New( |
| 2303 kExternalTypedDataInt8ArrayCid, data, data_length)); | 2303 kExternalTypedDataInt8ArrayCid, data, data_length)); |
| 2304 EXPECT(!int8_array.IsNull()); | 2304 EXPECT(!int8_array.IsNull()); |
| 2305 EXPECT_EQ(data_length, int8_array.Length()); | 2305 EXPECT_EQ(data_length, int8_array.Length()); |
| 2306 | 2306 |
| 2307 const ExternalTypedData& uint8_array = | 2307 const ExternalTypedData& uint8_array = |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2381 Dart_Handle h_lib = TestCase::LoadTestScript(kScript, NULL); | 2381 Dart_Handle h_lib = TestCase::LoadTestScript(kScript, NULL); |
| 2382 EXPECT_VALID(h_lib); | 2382 EXPECT_VALID(h_lib); |
| 2383 Library& lib = Library::Handle(); | 2383 Library& lib = Library::Handle(); |
| 2384 lib ^= Api::UnwrapHandle(h_lib); | 2384 lib ^= Api::UnwrapHandle(h_lib); |
| 2385 EXPECT(!lib.IsNull()); | 2385 EXPECT(!lib.IsNull()); |
| 2386 Dart_Handle result = Dart_Invoke(h_lib, NewString("main"), 0, NULL); | 2386 Dart_Handle result = Dart_Invoke(h_lib, NewString("main"), 0, NULL); |
| 2387 EXPECT_VALID(result); | 2387 EXPECT_VALID(result); |
| 2388 } | 2388 } |
| 2389 | 2389 |
| 2390 | 2390 |
| 2391 VM_TEST_CASE(EmbeddedScript) { | 2391 ISOLATE_UNIT_TEST_CASE(EmbeddedScript) { |
| 2392 const char* url_chars = "builtin:test-case"; | 2392 const char* url_chars = "builtin:test-case"; |
| 2393 const char* text = | 2393 const char* text = |
| 2394 /* 1 */ | 2394 /* 1 */ |
| 2395 "<!DOCTYPE html>\n" | 2395 "<!DOCTYPE html>\n" |
| 2396 /* 2 */ | 2396 /* 2 */ |
| 2397 " ... more junk ...\n" | 2397 " ... more junk ...\n" |
| 2398 /* 3 */ | 2398 /* 3 */ |
| 2399 " <script type='application/dart'>main() {\n" | 2399 " <script type='application/dart'>main() {\n" |
| 2400 /* 4 */ | 2400 /* 4 */ |
| 2401 " return 'foo';\n" | 2401 " return 'foo';\n" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2483 EXPECT_EQ(-1, first_idx.value()); | 2483 EXPECT_EQ(-1, first_idx.value()); |
| 2484 EXPECT_EQ(-1, last_idx.value()); | 2484 EXPECT_EQ(-1, last_idx.value()); |
| 2485 script.TokenRangeAtLine(1000, &first_idx, &last_idx); | 2485 script.TokenRangeAtLine(1000, &first_idx, &last_idx); |
| 2486 EXPECT_EQ(-1, first_idx.value()); | 2486 EXPECT_EQ(-1, first_idx.value()); |
| 2487 EXPECT_EQ(-1, last_idx.value()); | 2487 EXPECT_EQ(-1, last_idx.value()); |
| 2488 | 2488 |
| 2489 free(src_chars); | 2489 free(src_chars); |
| 2490 } | 2490 } |
| 2491 | 2491 |
| 2492 | 2492 |
| 2493 VM_TEST_CASE(Context) { | 2493 ISOLATE_UNIT_TEST_CASE(Context) { |
| 2494 const int kNumVariables = 5; | 2494 const int kNumVariables = 5; |
| 2495 const Context& parent_context = Context::Handle(Context::New(0)); | 2495 const Context& parent_context = Context::Handle(Context::New(0)); |
| 2496 const Context& context = Context::Handle(Context::New(kNumVariables)); | 2496 const Context& context = Context::Handle(Context::New(kNumVariables)); |
| 2497 context.set_parent(parent_context); | 2497 context.set_parent(parent_context); |
| 2498 EXPECT_EQ(kNumVariables, context.num_variables()); | 2498 EXPECT_EQ(kNumVariables, context.num_variables()); |
| 2499 EXPECT(Context::Handle(context.parent()).raw() == parent_context.raw()); | 2499 EXPECT(Context::Handle(context.parent()).raw() == parent_context.raw()); |
| 2500 EXPECT_EQ(0, Context::Handle(context.parent()).num_variables()); | 2500 EXPECT_EQ(0, Context::Handle(context.parent()).num_variables()); |
| 2501 EXPECT(Context::Handle(Context::Handle(context.parent()).parent()).IsNull()); | 2501 EXPECT(Context::Handle(Context::Handle(context.parent()).parent()).IsNull()); |
| 2502 Object& variable = Object::Handle(context.At(0)); | 2502 Object& variable = Object::Handle(context.At(0)); |
| 2503 EXPECT(variable.IsNull()); | 2503 EXPECT(variable.IsNull()); |
| 2504 variable = context.At(kNumVariables - 1); | 2504 variable = context.At(kNumVariables - 1); |
| 2505 EXPECT(variable.IsNull()); | 2505 EXPECT(variable.IsNull()); |
| 2506 context.SetAt(0, Smi::Handle(Smi::New(2))); | 2506 context.SetAt(0, Smi::Handle(Smi::New(2))); |
| 2507 context.SetAt(2, Smi::Handle(Smi::New(3))); | 2507 context.SetAt(2, Smi::Handle(Smi::New(3))); |
| 2508 Smi& smi = Smi::Handle(); | 2508 Smi& smi = Smi::Handle(); |
| 2509 smi ^= context.At(0); | 2509 smi ^= context.At(0); |
| 2510 EXPECT_EQ(2, smi.Value()); | 2510 EXPECT_EQ(2, smi.Value()); |
| 2511 smi ^= context.At(2); | 2511 smi ^= context.At(2); |
| 2512 EXPECT_EQ(3, smi.Value()); | 2512 EXPECT_EQ(3, smi.Value()); |
| 2513 } | 2513 } |
| 2514 | 2514 |
| 2515 | 2515 |
| 2516 VM_TEST_CASE(ContextScope) { | 2516 ISOLATE_UNIT_TEST_CASE(ContextScope) { |
| 2517 const intptr_t parent_scope_function_level = 0; | 2517 const intptr_t parent_scope_function_level = 0; |
| 2518 LocalScope* parent_scope = | 2518 LocalScope* parent_scope = |
| 2519 new LocalScope(NULL, parent_scope_function_level, 0); | 2519 new LocalScope(NULL, parent_scope_function_level, 0); |
| 2520 | 2520 |
| 2521 const intptr_t local_scope_function_level = 1; | 2521 const intptr_t local_scope_function_level = 1; |
| 2522 LocalScope* local_scope = | 2522 LocalScope* local_scope = |
| 2523 new LocalScope(parent_scope, local_scope_function_level, 0); | 2523 new LocalScope(parent_scope, local_scope_function_level, 0); |
| 2524 | 2524 |
| 2525 const Type& dynamic_type = Type::ZoneHandle(Type::DynamicType()); | 2525 const Type& dynamic_type = Type::ZoneHandle(Type::DynamicType()); |
| 2526 const String& a = String::ZoneHandle(Symbols::New(thread, "a")); | 2526 const String& a = String::ZoneHandle(Symbols::New(thread, "a")); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2591 EXPECT(outer_scope->LocalLookupVariable(b) == NULL); | 2591 EXPECT(outer_scope->LocalLookupVariable(b) == NULL); |
| 2592 | 2592 |
| 2593 var_c = outer_scope->LocalLookupVariable(c); | 2593 var_c = outer_scope->LocalLookupVariable(c); |
| 2594 EXPECT(var_c->is_captured()); | 2594 EXPECT(var_c->is_captured()); |
| 2595 EXPECT_EQ(1, var_c->index()); | 2595 EXPECT_EQ(1, var_c->index()); |
| 2596 EXPECT_EQ(parent_scope_context_level - local_scope_context_level, | 2596 EXPECT_EQ(parent_scope_context_level - local_scope_context_level, |
| 2597 var_c->owner()->context_level()); // Adjusted context level. | 2597 var_c->owner()->context_level()); // Adjusted context level. |
| 2598 } | 2598 } |
| 2599 | 2599 |
| 2600 | 2600 |
| 2601 VM_TEST_CASE(Closure) { | 2601 ISOLATE_UNIT_TEST_CASE(Closure) { |
| 2602 // Allocate the class first. | 2602 // Allocate the class first. |
| 2603 const String& class_name = String::Handle(Symbols::New(thread, "MyClass")); | 2603 const String& class_name = String::Handle(Symbols::New(thread, "MyClass")); |
| 2604 const Script& script = Script::Handle(); | 2604 const Script& script = Script::Handle(); |
| 2605 const Class& cls = Class::Handle(CreateDummyClass(class_name, script)); | 2605 const Class& cls = Class::Handle(CreateDummyClass(class_name, script)); |
| 2606 const Array& functions = Array::Handle(Array::New(1)); | 2606 const Array& functions = Array::Handle(Array::New(1)); |
| 2607 | 2607 |
| 2608 const Context& context = Context::Handle(Context::New(0)); | 2608 const Context& context = Context::Handle(Context::New(0)); |
| 2609 Function& parent = Function::Handle(); | 2609 Function& parent = Function::Handle(); |
| 2610 const String& parent_name = String::Handle(Symbols::New(thread, "foo_papa")); | 2610 const String& parent_name = String::Handle(Symbols::New(thread, "foo_papa")); |
| 2611 parent = | 2611 parent = |
| 2612 Function::New(parent_name, RawFunction::kRegularFunction, false, false, | 2612 Function::New(parent_name, RawFunction::kRegularFunction, false, false, |
| 2613 false, false, false, cls, TokenPosition::kMinSource); | 2613 false, false, false, cls, TokenPosition::kMinSource); |
| 2614 functions.SetAt(0, parent); | 2614 functions.SetAt(0, parent); |
| 2615 cls.SetFunctions(functions); | 2615 cls.SetFunctions(functions); |
| 2616 | 2616 |
| 2617 Function& function = Function::Handle(); | 2617 Function& function = Function::Handle(); |
| 2618 const String& function_name = String::Handle(Symbols::New(thread, "foo")); | 2618 const String& function_name = String::Handle(Symbols::New(thread, "foo")); |
| 2619 function = Function::NewClosureFunction(function_name, parent, | 2619 function = Function::NewClosureFunction(function_name, parent, |
| 2620 TokenPosition::kMinSource); | 2620 TokenPosition::kMinSource); |
| 2621 const Closure& closure = Closure::Handle(Closure::New(function, context)); | 2621 const Closure& closure = Closure::Handle(Closure::New(function, context)); |
| 2622 const Class& closure_class = Class::Handle(closure.clazz()); | 2622 const Class& closure_class = Class::Handle(closure.clazz()); |
| 2623 EXPECT_EQ(closure_class.id(), kClosureCid); | 2623 EXPECT_EQ(closure_class.id(), kClosureCid); |
| 2624 const Function& closure_function = Function::Handle(closure.function()); | 2624 const Function& closure_function = Function::Handle(closure.function()); |
| 2625 EXPECT_EQ(closure_function.raw(), function.raw()); | 2625 EXPECT_EQ(closure_function.raw(), function.raw()); |
| 2626 const Context& closure_context = Context::Handle(closure.context()); | 2626 const Context& closure_context = Context::Handle(closure.context()); |
| 2627 EXPECT_EQ(closure_context.raw(), context.raw()); | 2627 EXPECT_EQ(closure_context.raw(), context.raw()); |
| 2628 } | 2628 } |
| 2629 | 2629 |
| 2630 | 2630 |
| 2631 VM_TEST_CASE(ObjectPrinting) { | 2631 ISOLATE_UNIT_TEST_CASE(ObjectPrinting) { |
| 2632 // Simple Smis. | 2632 // Simple Smis. |
| 2633 EXPECT_STREQ("2", Smi::Handle(Smi::New(2)).ToCString()); | 2633 EXPECT_STREQ("2", Smi::Handle(Smi::New(2)).ToCString()); |
| 2634 EXPECT_STREQ("-15", Smi::Handle(Smi::New(-15)).ToCString()); | 2634 EXPECT_STREQ("-15", Smi::Handle(Smi::New(-15)).ToCString()); |
| 2635 | 2635 |
| 2636 // bool class and true/false values. | 2636 // bool class and true/false values. |
| 2637 ObjectStore* object_store = Isolate::Current()->object_store(); | 2637 ObjectStore* object_store = Isolate::Current()->object_store(); |
| 2638 const Class& bool_class = Class::Handle(object_store->bool_class()); | 2638 const Class& bool_class = Class::Handle(object_store->bool_class()); |
| 2639 EXPECT_STREQ("Library:'dart:core' Class: bool", bool_class.ToCString()); | 2639 EXPECT_STREQ("Library:'dart:core' Class: bool", bool_class.ToCString()); |
| 2640 EXPECT_STREQ("true", Bool::True().ToCString()); | 2640 EXPECT_STREQ("true", Bool::True().ToCString()); |
| 2641 EXPECT_STREQ("false", Bool::False().ToCString()); | 2641 EXPECT_STREQ("false", Bool::False().ToCString()); |
| 2642 | 2642 |
| 2643 // Strings. | 2643 // Strings. |
| 2644 EXPECT_STREQ("Sugarbowl", | 2644 EXPECT_STREQ("Sugarbowl", |
| 2645 String::Handle(String::New("Sugarbowl")).ToCString()); | 2645 String::Handle(String::New("Sugarbowl")).ToCString()); |
| 2646 } | 2646 } |
| 2647 | 2647 |
| 2648 | 2648 |
| 2649 VM_TEST_CASE(CheckedHandle) { | 2649 ISOLATE_UNIT_TEST_CASE(CheckedHandle) { |
| 2650 // Ensure that null handles have the correct C++ vtable setup. | 2650 // Ensure that null handles have the correct C++ vtable setup. |
| 2651 const String& str1 = String::Handle(); | 2651 const String& str1 = String::Handle(); |
| 2652 EXPECT(str1.IsString()); | 2652 EXPECT(str1.IsString()); |
| 2653 EXPECT(str1.IsNull()); | 2653 EXPECT(str1.IsNull()); |
| 2654 const String& str2 = String::CheckedHandle(Object::null()); | 2654 const String& str2 = String::CheckedHandle(Object::null()); |
| 2655 EXPECT(str2.IsString()); | 2655 EXPECT(str2.IsString()); |
| 2656 EXPECT(str2.IsNull()); | 2656 EXPECT(str2.IsNull()); |
| 2657 String& str3 = String::Handle(); | 2657 String& str3 = String::Handle(); |
| 2658 str3 ^= Object::null(); | 2658 str3 ^= Object::null(); |
| 2659 EXPECT(str3.IsString()); | 2659 EXPECT(str3.IsString()); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 2683 const Library& owner_library = Library::Handle(CreateDummyLibrary(lib_name)); | 2683 const Library& owner_library = Library::Handle(CreateDummyLibrary(lib_name)); |
| 2684 owner_class.set_library(owner_library); | 2684 owner_class.set_library(owner_library); |
| 2685 const String& function_name = String::ZoneHandle(Symbols::New(thread, name)); | 2685 const String& function_name = String::ZoneHandle(Symbols::New(thread, name)); |
| 2686 return Function::New(function_name, RawFunction::kRegularFunction, true, | 2686 return Function::New(function_name, RawFunction::kRegularFunction, true, |
| 2687 false, false, false, false, owner_class, | 2687 false, false, false, false, owner_class, |
| 2688 TokenPosition::kMinSource); | 2688 TokenPosition::kMinSource); |
| 2689 } | 2689 } |
| 2690 | 2690 |
| 2691 | 2691 |
| 2692 // Test for Code and Instruction object creation. | 2692 // Test for Code and Instruction object creation. |
| 2693 VM_TEST_CASE(Code) { | 2693 ISOLATE_UNIT_TEST_CASE(Code) { |
| 2694 extern void GenerateIncrement(Assembler * assembler); | 2694 extern void GenerateIncrement(Assembler * assembler); |
| 2695 Assembler _assembler_; | 2695 Assembler _assembler_; |
| 2696 GenerateIncrement(&_assembler_); | 2696 GenerateIncrement(&_assembler_); |
| 2697 const Function& function = Function::Handle(CreateFunction("Test_Code")); | 2697 const Function& function = Function::Handle(CreateFunction("Test_Code")); |
| 2698 Code& code = Code::Handle(Code::FinalizeCode(function, &_assembler_)); | 2698 Code& code = Code::Handle(Code::FinalizeCode(function, &_assembler_)); |
| 2699 function.AttachCode(code); | 2699 function.AttachCode(code); |
| 2700 const Instructions& instructions = Instructions::Handle(code.instructions()); | 2700 const Instructions& instructions = Instructions::Handle(code.instructions()); |
| 2701 uword payload_start = instructions.PayloadStart(); | 2701 uword payload_start = instructions.PayloadStart(); |
| 2702 EXPECT_EQ(instructions.raw(), Instructions::FromPayloadStart(payload_start)); | 2702 EXPECT_EQ(instructions.raw(), Instructions::FromPayloadStart(payload_start)); |
| 2703 const Object& result = | 2703 const Object& result = |
| 2704 Object::Handle(DartEntry::InvokeFunction(function, Array::empty_array())); | 2704 Object::Handle(DartEntry::InvokeFunction(function, Array::empty_array())); |
| 2705 EXPECT_EQ(1, Smi::Cast(result).Value()); | 2705 EXPECT_EQ(1, Smi::Cast(result).Value()); |
| 2706 } | 2706 } |
| 2707 | 2707 |
| 2708 | 2708 |
| 2709 // Test for immutability of generated instructions. The test crashes with a | 2709 // Test for immutability of generated instructions. The test crashes with a |
| 2710 // segmentation fault when writing into it. | 2710 // segmentation fault when writing into it. |
| 2711 VM_TEST_CASE(CodeImmutability) { | 2711 ISOLATE_UNIT_TEST_CASE(CodeImmutability) { |
| 2712 extern void GenerateIncrement(Assembler * assembler); | 2712 extern void GenerateIncrement(Assembler * assembler); |
| 2713 Assembler _assembler_; | 2713 Assembler _assembler_; |
| 2714 GenerateIncrement(&_assembler_); | 2714 GenerateIncrement(&_assembler_); |
| 2715 const Function& function = Function::Handle(CreateFunction("Test_Code")); | 2715 const Function& function = Function::Handle(CreateFunction("Test_Code")); |
| 2716 Code& code = Code::Handle(Code::FinalizeCode(function, &_assembler_)); | 2716 Code& code = Code::Handle(Code::FinalizeCode(function, &_assembler_)); |
| 2717 function.AttachCode(code); | 2717 function.AttachCode(code); |
| 2718 Instructions& instructions = Instructions::Handle(code.instructions()); | 2718 Instructions& instructions = Instructions::Handle(code.instructions()); |
| 2719 uword payload_start = instructions.PayloadStart(); | 2719 uword payload_start = instructions.PayloadStart(); |
| 2720 EXPECT_EQ(instructions.raw(), Instructions::FromPayloadStart(payload_start)); | 2720 EXPECT_EQ(instructions.raw(), Instructions::FromPayloadStart(payload_start)); |
| 2721 // Try writing into the generated code, expected to crash. | 2721 // Try writing into the generated code, expected to crash. |
| 2722 *(reinterpret_cast<char*>(payload_start) + 1) = 1; | 2722 *(reinterpret_cast<char*>(payload_start) + 1) = 1; |
| 2723 if (!FLAG_write_protect_code) { | 2723 if (!FLAG_write_protect_code) { |
| 2724 // Since this test is expected to crash, crash if write protection of code | 2724 // Since this test is expected to crash, crash if write protection of code |
| 2725 // is switched off. | 2725 // is switched off. |
| 2726 // TODO(regis, fschneider): Should this be FATAL() instead? | 2726 // TODO(regis, fschneider): Should this be FATAL() instead? |
| 2727 OS::DebugBreak(); | 2727 OS::DebugBreak(); |
| 2728 } | 2728 } |
| 2729 } | 2729 } |
| 2730 | 2730 |
| 2731 | 2731 |
| 2732 // Test for Embedded String object in the instructions. | 2732 // Test for Embedded String object in the instructions. |
| 2733 VM_TEST_CASE(EmbedStringInCode) { | 2733 ISOLATE_UNIT_TEST_CASE(EmbedStringInCode) { |
| 2734 extern void GenerateEmbedStringInCode(Assembler * assembler, const char* str); | 2734 extern void GenerateEmbedStringInCode(Assembler * assembler, const char* str); |
| 2735 const char* kHello = "Hello World!"; | 2735 const char* kHello = "Hello World!"; |
| 2736 word expected_length = static_cast<word>(strlen(kHello)); | 2736 word expected_length = static_cast<word>(strlen(kHello)); |
| 2737 Assembler _assembler_; | 2737 Assembler _assembler_; |
| 2738 GenerateEmbedStringInCode(&_assembler_, kHello); | 2738 GenerateEmbedStringInCode(&_assembler_, kHello); |
| 2739 const Function& function = | 2739 const Function& function = |
| 2740 Function::Handle(CreateFunction("Test_EmbedStringInCode")); | 2740 Function::Handle(CreateFunction("Test_EmbedStringInCode")); |
| 2741 const Code& code = Code::Handle(Code::FinalizeCode(function, &_assembler_)); | 2741 const Code& code = Code::Handle(Code::FinalizeCode(function, &_assembler_)); |
| 2742 function.AttachCode(code); | 2742 function.AttachCode(code); |
| 2743 const Object& result = | 2743 const Object& result = |
| 2744 Object::Handle(DartEntry::InvokeFunction(function, Array::empty_array())); | 2744 Object::Handle(DartEntry::InvokeFunction(function, Array::empty_array())); |
| 2745 EXPECT(result.raw()->IsHeapObject()); | 2745 EXPECT(result.raw()->IsHeapObject()); |
| 2746 String& string_object = String::Handle(); | 2746 String& string_object = String::Handle(); |
| 2747 string_object ^= result.raw(); | 2747 string_object ^= result.raw(); |
| 2748 EXPECT(string_object.Length() == expected_length); | 2748 EXPECT(string_object.Length() == expected_length); |
| 2749 for (int i = 0; i < expected_length; i++) { | 2749 for (int i = 0; i < expected_length; i++) { |
| 2750 EXPECT(string_object.CharAt(i) == kHello[i]); | 2750 EXPECT(string_object.CharAt(i) == kHello[i]); |
| 2751 } | 2751 } |
| 2752 } | 2752 } |
| 2753 | 2753 |
| 2754 | 2754 |
| 2755 // Test for Embedded Smi object in the instructions. | 2755 // Test for Embedded Smi object in the instructions. |
| 2756 VM_TEST_CASE(EmbedSmiInCode) { | 2756 ISOLATE_UNIT_TEST_CASE(EmbedSmiInCode) { |
| 2757 extern void GenerateEmbedSmiInCode(Assembler * assembler, intptr_t value); | 2757 extern void GenerateEmbedSmiInCode(Assembler * assembler, intptr_t value); |
| 2758 const intptr_t kSmiTestValue = 5; | 2758 const intptr_t kSmiTestValue = 5; |
| 2759 Assembler _assembler_; | 2759 Assembler _assembler_; |
| 2760 GenerateEmbedSmiInCode(&_assembler_, kSmiTestValue); | 2760 GenerateEmbedSmiInCode(&_assembler_, kSmiTestValue); |
| 2761 const Function& function = | 2761 const Function& function = |
| 2762 Function::Handle(CreateFunction("Test_EmbedSmiInCode")); | 2762 Function::Handle(CreateFunction("Test_EmbedSmiInCode")); |
| 2763 const Code& code = Code::Handle(Code::FinalizeCode(function, &_assembler_)); | 2763 const Code& code = Code::Handle(Code::FinalizeCode(function, &_assembler_)); |
| 2764 function.AttachCode(code); | 2764 function.AttachCode(code); |
| 2765 const Object& result = | 2765 const Object& result = |
| 2766 Object::Handle(DartEntry::InvokeFunction(function, Array::empty_array())); | 2766 Object::Handle(DartEntry::InvokeFunction(function, Array::empty_array())); |
| 2767 EXPECT(Smi::Cast(result).Value() == kSmiTestValue); | 2767 EXPECT(Smi::Cast(result).Value() == kSmiTestValue); |
| 2768 } | 2768 } |
| 2769 | 2769 |
| 2770 | 2770 |
| 2771 #if defined(ARCH_IS_64_BIT) | 2771 #if defined(ARCH_IS_64_BIT) |
| 2772 // Test for Embedded Smi object in the instructions. | 2772 // Test for Embedded Smi object in the instructions. |
| 2773 VM_TEST_CASE(EmbedSmiIn64BitCode) { | 2773 ISOLATE_UNIT_TEST_CASE(EmbedSmiIn64BitCode) { |
| 2774 extern void GenerateEmbedSmiInCode(Assembler * assembler, intptr_t value); | 2774 extern void GenerateEmbedSmiInCode(Assembler * assembler, intptr_t value); |
| 2775 const intptr_t kSmiTestValue = DART_INT64_C(5) << 32; | 2775 const intptr_t kSmiTestValue = DART_INT64_C(5) << 32; |
| 2776 Assembler _assembler_; | 2776 Assembler _assembler_; |
| 2777 GenerateEmbedSmiInCode(&_assembler_, kSmiTestValue); | 2777 GenerateEmbedSmiInCode(&_assembler_, kSmiTestValue); |
| 2778 const Function& function = | 2778 const Function& function = |
| 2779 Function::Handle(CreateFunction("Test_EmbedSmiIn64BitCode")); | 2779 Function::Handle(CreateFunction("Test_EmbedSmiIn64BitCode")); |
| 2780 const Code& code = Code::Handle(Code::FinalizeCode(function, &_assembler_)); | 2780 const Code& code = Code::Handle(Code::FinalizeCode(function, &_assembler_)); |
| 2781 function.AttachCode(code); | 2781 function.AttachCode(code); |
| 2782 const Object& result = | 2782 const Object& result = |
| 2783 Object::Handle(DartEntry::InvokeFunction(function, Array::empty_array())); | 2783 Object::Handle(DartEntry::InvokeFunction(function, Array::empty_array())); |
| 2784 EXPECT(Smi::Cast(result).Value() == kSmiTestValue); | 2784 EXPECT(Smi::Cast(result).Value() == kSmiTestValue); |
| 2785 } | 2785 } |
| 2786 #endif // ARCH_IS_64_BIT | 2786 #endif // ARCH_IS_64_BIT |
| 2787 | 2787 |
| 2788 | 2788 |
| 2789 VM_TEST_CASE(ExceptionHandlers) { | 2789 ISOLATE_UNIT_TEST_CASE(ExceptionHandlers) { |
| 2790 const int kNumEntries = 4; | 2790 const int kNumEntries = 4; |
| 2791 // Add an exception handler table to the code. | 2791 // Add an exception handler table to the code. |
| 2792 ExceptionHandlers& exception_handlers = ExceptionHandlers::Handle(); | 2792 ExceptionHandlers& exception_handlers = ExceptionHandlers::Handle(); |
| 2793 exception_handlers ^= ExceptionHandlers::New(kNumEntries); | 2793 exception_handlers ^= ExceptionHandlers::New(kNumEntries); |
| 2794 const bool kNeedsStackTrace = true; | 2794 const bool kNeedsStackTrace = true; |
| 2795 const bool kNoStackTrace = false; | 2795 const bool kNoStackTrace = false; |
| 2796 exception_handlers.SetHandlerInfo(0, -1, 20u, kNeedsStackTrace, false); | 2796 exception_handlers.SetHandlerInfo(0, -1, 20u, kNeedsStackTrace, false); |
| 2797 exception_handlers.SetHandlerInfo(1, 0, 30u, kNeedsStackTrace, false); | 2797 exception_handlers.SetHandlerInfo(1, 0, 30u, kNeedsStackTrace, false); |
| 2798 exception_handlers.SetHandlerInfo(2, -1, 40u, kNoStackTrace, true); | 2798 exception_handlers.SetHandlerInfo(2, -1, 40u, kNoStackTrace, true); |
| 2799 exception_handlers.SetHandlerInfo(3, 1, 150u, kNoStackTrace, true); | 2799 exception_handlers.SetHandlerInfo(3, 1, 150u, kNoStackTrace, true); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 2817 EXPECT(handlers.NeedsStackTrace(0)); | 2817 EXPECT(handlers.NeedsStackTrace(0)); |
| 2818 EXPECT(!handlers.HasCatchAll(0)); | 2818 EXPECT(!handlers.HasCatchAll(0)); |
| 2819 EXPECT_EQ(20u, info.handler_pc_offset); | 2819 EXPECT_EQ(20u, info.handler_pc_offset); |
| 2820 EXPECT_EQ(1, handlers.OuterTryIndex(3)); | 2820 EXPECT_EQ(1, handlers.OuterTryIndex(3)); |
| 2821 EXPECT_EQ(150u, handlers.HandlerPCOffset(3)); | 2821 EXPECT_EQ(150u, handlers.HandlerPCOffset(3)); |
| 2822 EXPECT(!handlers.NeedsStackTrace(3)); | 2822 EXPECT(!handlers.NeedsStackTrace(3)); |
| 2823 EXPECT(handlers.HasCatchAll(3)); | 2823 EXPECT(handlers.HasCatchAll(3)); |
| 2824 } | 2824 } |
| 2825 | 2825 |
| 2826 | 2826 |
| 2827 VM_TEST_CASE(PcDescriptors) { | 2827 ISOLATE_UNIT_TEST_CASE(PcDescriptors) { |
| 2828 DescriptorList* builder = new DescriptorList(0); | 2828 DescriptorList* builder = new DescriptorList(0); |
| 2829 | 2829 |
| 2830 // kind, pc_offset, deopt_id, token_pos, try_index | 2830 // kind, pc_offset, deopt_id, token_pos, try_index |
| 2831 builder->AddDescriptor(RawPcDescriptors::kOther, 10, 1, TokenPosition(20), 1); | 2831 builder->AddDescriptor(RawPcDescriptors::kOther, 10, 1, TokenPosition(20), 1); |
| 2832 builder->AddDescriptor(RawPcDescriptors::kDeopt, 20, 2, TokenPosition(30), 0); | 2832 builder->AddDescriptor(RawPcDescriptors::kDeopt, 20, 2, TokenPosition(30), 0); |
| 2833 builder->AddDescriptor(RawPcDescriptors::kOther, 30, 3, TokenPosition(40), 1); | 2833 builder->AddDescriptor(RawPcDescriptors::kOther, 30, 3, TokenPosition(40), 1); |
| 2834 builder->AddDescriptor(RawPcDescriptors::kOther, 10, 4, TokenPosition(40), 2); | 2834 builder->AddDescriptor(RawPcDescriptors::kOther, 10, 4, TokenPosition(40), 2); |
| 2835 builder->AddDescriptor(RawPcDescriptors::kOther, 10, 5, TokenPosition(80), 3); | 2835 builder->AddDescriptor(RawPcDescriptors::kOther, 10, 5, TokenPosition(80), 3); |
| 2836 builder->AddDescriptor(RawPcDescriptors::kOther, 80, 6, TokenPosition(150), | 2836 builder->AddDescriptor(RawPcDescriptors::kOther, 80, 6, TokenPosition(150), |
| 2837 3); | 2837 3); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2875 | 2875 |
| 2876 EXPECT_EQ(3, iter.TryIndex()); | 2876 EXPECT_EQ(3, iter.TryIndex()); |
| 2877 EXPECT_EQ(static_cast<uword>(80), iter.PcOffset()); | 2877 EXPECT_EQ(static_cast<uword>(80), iter.PcOffset()); |
| 2878 EXPECT_EQ(150, iter.TokenPos().value()); | 2878 EXPECT_EQ(150, iter.TokenPos().value()); |
| 2879 EXPECT_EQ(RawPcDescriptors::kOther, iter.Kind()); | 2879 EXPECT_EQ(RawPcDescriptors::kOther, iter.Kind()); |
| 2880 | 2880 |
| 2881 EXPECT_EQ(false, iter.MoveNext()); | 2881 EXPECT_EQ(false, iter.MoveNext()); |
| 2882 } | 2882 } |
| 2883 | 2883 |
| 2884 | 2884 |
| 2885 VM_TEST_CASE(PcDescriptorsLargeDeltas) { | 2885 ISOLATE_UNIT_TEST_CASE(PcDescriptorsLargeDeltas) { |
| 2886 DescriptorList* builder = new DescriptorList(0); | 2886 DescriptorList* builder = new DescriptorList(0); |
| 2887 | 2887 |
| 2888 // kind, pc_offset, deopt_id, token_pos, try_index | 2888 // kind, pc_offset, deopt_id, token_pos, try_index |
| 2889 builder->AddDescriptor(RawPcDescriptors::kOther, 100, 1, TokenPosition(200), | 2889 builder->AddDescriptor(RawPcDescriptors::kOther, 100, 1, TokenPosition(200), |
| 2890 1); | 2890 1); |
| 2891 builder->AddDescriptor(RawPcDescriptors::kDeopt, 200, 2, TokenPosition(300), | 2891 builder->AddDescriptor(RawPcDescriptors::kDeopt, 200, 2, TokenPosition(300), |
| 2892 0); | 2892 0); |
| 2893 builder->AddDescriptor(RawPcDescriptors::kOther, 300, 3, TokenPosition(400), | 2893 builder->AddDescriptor(RawPcDescriptors::kOther, 300, 3, TokenPosition(400), |
| 2894 1); | 2894 1); |
| 2895 builder->AddDescriptor(RawPcDescriptors::kOther, 100, 4, TokenPosition(0), 2); | 2895 builder->AddDescriptor(RawPcDescriptors::kOther, 100, 4, TokenPosition(0), 2); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2957 const Class& cls = Class::Handle(CreateTestClass("global:")); | 2957 const Class& cls = Class::Handle(CreateTestClass("global:")); |
| 2958 const String& field_name = | 2958 const String& field_name = |
| 2959 String::Handle(Symbols::New(Thread::Current(), name)); | 2959 String::Handle(Symbols::New(Thread::Current(), name)); |
| 2960 const Field& field = Field::Handle( | 2960 const Field& field = Field::Handle( |
| 2961 Field::New(field_name, true, false, false, true, cls, | 2961 Field::New(field_name, true, false, false, true, cls, |
| 2962 Object::dynamic_type(), TokenPosition::kMinSource)); | 2962 Object::dynamic_type(), TokenPosition::kMinSource)); |
| 2963 return field.raw(); | 2963 return field.raw(); |
| 2964 } | 2964 } |
| 2965 | 2965 |
| 2966 | 2966 |
| 2967 VM_TEST_CASE(ClassDictionaryIterator) { | 2967 ISOLATE_UNIT_TEST_CASE(ClassDictionaryIterator) { |
| 2968 Class& ae66 = Class::ZoneHandle(CreateTestClass("Ae6/6")); | 2968 Class& ae66 = Class::ZoneHandle(CreateTestClass("Ae6/6")); |
| 2969 Class& re44 = Class::ZoneHandle(CreateTestClass("Re4/4")); | 2969 Class& re44 = Class::ZoneHandle(CreateTestClass("Re4/4")); |
| 2970 Field& ce68 = Field::ZoneHandle(CreateTestField("Ce6/8")); | 2970 Field& ce68 = Field::ZoneHandle(CreateTestField("Ce6/8")); |
| 2971 Field& tee = Field::ZoneHandle(CreateTestField("TEE")); | 2971 Field& tee = Field::ZoneHandle(CreateTestField("TEE")); |
| 2972 String& url = String::ZoneHandle(String::New("SBB")); | 2972 String& url = String::ZoneHandle(String::New("SBB")); |
| 2973 Library& lib = Library::Handle(Library::New(url)); | 2973 Library& lib = Library::Handle(Library::New(url)); |
| 2974 lib.AddClass(ae66); | 2974 lib.AddClass(ae66); |
| 2975 lib.AddObject(ce68, String::ZoneHandle(ce68.name())); | 2975 lib.AddObject(ce68, String::ZoneHandle(ce68.name())); |
| 2976 lib.AddClass(re44); | 2976 lib.AddClass(re44); |
| 2977 lib.AddObject(tee, String::ZoneHandle(tee.name())); | 2977 lib.AddObject(tee, String::ZoneHandle(tee.name())); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 2996 const bool is_const = false; | 2996 const bool is_const = false; |
| 2997 const bool is_abstract = false; | 2997 const bool is_abstract = false; |
| 2998 const bool is_external = false; | 2998 const bool is_external = false; |
| 2999 const bool is_native = false; | 2999 const bool is_native = false; |
| 3000 return Function::New(function_name, RawFunction::kRegularFunction, is_static, | 3000 return Function::New(function_name, RawFunction::kRegularFunction, is_static, |
| 3001 is_const, is_abstract, is_external, is_native, cls, | 3001 is_const, is_abstract, is_external, is_native, cls, |
| 3002 TokenPosition::kMinSource); | 3002 TokenPosition::kMinSource); |
| 3003 } | 3003 } |
| 3004 | 3004 |
| 3005 | 3005 |
| 3006 VM_TEST_CASE(ICData) { | 3006 ISOLATE_UNIT_TEST_CASE(ICData) { |
| 3007 Function& function = Function::Handle(GetDummyTarget("Bern")); | 3007 Function& function = Function::Handle(GetDummyTarget("Bern")); |
| 3008 const intptr_t id = 12; | 3008 const intptr_t id = 12; |
| 3009 const intptr_t num_args_tested = 1; | 3009 const intptr_t num_args_tested = 1; |
| 3010 const String& target_name = String::Handle(Symbols::New(thread, "Thun")); | 3010 const String& target_name = String::Handle(Symbols::New(thread, "Thun")); |
| 3011 const Array& args_descriptor = | 3011 const Array& args_descriptor = |
| 3012 Array::Handle(ArgumentsDescriptor::New(1, Object::null_array())); | 3012 Array::Handle(ArgumentsDescriptor::New(1, Object::null_array())); |
| 3013 ICData& o1 = ICData::Handle(); | 3013 ICData& o1 = ICData::Handle(); |
| 3014 o1 = ICData::New(function, target_name, args_descriptor, id, num_args_tested, | 3014 o1 = ICData::New(function, target_name, args_descriptor, id, num_args_tested, |
| 3015 false); | 3015 false); |
| 3016 EXPECT_EQ(1, o1.NumArgsTested()); | 3016 EXPECT_EQ(1, o1.NumArgsTested()); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3069 | 3069 |
| 3070 // Check ICData for unoptimized static calls. | 3070 // Check ICData for unoptimized static calls. |
| 3071 const intptr_t kNumArgsChecked = 0; | 3071 const intptr_t kNumArgsChecked = 0; |
| 3072 const ICData& scall_icdata = ICData::Handle(ICData::New( | 3072 const ICData& scall_icdata = ICData::Handle(ICData::New( |
| 3073 function, target_name, args_descriptor, 57, kNumArgsChecked, false)); | 3073 function, target_name, args_descriptor, 57, kNumArgsChecked, false)); |
| 3074 scall_icdata.AddTarget(target1); | 3074 scall_icdata.AddTarget(target1); |
| 3075 EXPECT_EQ(target1.raw(), scall_icdata.GetTargetAt(0)); | 3075 EXPECT_EQ(target1.raw(), scall_icdata.GetTargetAt(0)); |
| 3076 } | 3076 } |
| 3077 | 3077 |
| 3078 | 3078 |
| 3079 VM_TEST_CASE(SubtypeTestCache) { | 3079 ISOLATE_UNIT_TEST_CASE(SubtypeTestCache) { |
| 3080 String& class_name = String::Handle(Symbols::New(thread, "EmptyClass")); | 3080 String& class_name = String::Handle(Symbols::New(thread, "EmptyClass")); |
| 3081 Script& script = Script::Handle(); | 3081 Script& script = Script::Handle(); |
| 3082 const Class& empty_class = | 3082 const Class& empty_class = |
| 3083 Class::Handle(CreateDummyClass(class_name, script)); | 3083 Class::Handle(CreateDummyClass(class_name, script)); |
| 3084 SubtypeTestCache& cache = SubtypeTestCache::Handle(SubtypeTestCache::New()); | 3084 SubtypeTestCache& cache = SubtypeTestCache::Handle(SubtypeTestCache::New()); |
| 3085 EXPECT(!cache.IsNull()); | 3085 EXPECT(!cache.IsNull()); |
| 3086 EXPECT_EQ(0, cache.NumberOfChecks()); | 3086 EXPECT_EQ(0, cache.NumberOfChecks()); |
| 3087 const Object& class_id_or_fun = Object::Handle(Smi::New(empty_class.id())); | 3087 const Object& class_id_or_fun = Object::Handle(Smi::New(empty_class.id())); |
| 3088 const TypeArguments& targ_0 = TypeArguments::Handle(TypeArguments::New(2)); | 3088 const TypeArguments& targ_0 = TypeArguments::Handle(TypeArguments::New(2)); |
| 3089 const TypeArguments& targ_1 = TypeArguments::Handle(TypeArguments::New(3)); | 3089 const TypeArguments& targ_1 = TypeArguments::Handle(TypeArguments::New(3)); |
| 3090 cache.AddCheck(class_id_or_fun, targ_0, targ_1, Bool::True()); | 3090 cache.AddCheck(class_id_or_fun, targ_0, targ_1, Bool::True()); |
| 3091 EXPECT_EQ(1, cache.NumberOfChecks()); | 3091 EXPECT_EQ(1, cache.NumberOfChecks()); |
| 3092 Object& test_class_id_or_fun = Object::Handle(); | 3092 Object& test_class_id_or_fun = Object::Handle(); |
| 3093 TypeArguments& test_targ_0 = TypeArguments::Handle(); | 3093 TypeArguments& test_targ_0 = TypeArguments::Handle(); |
| 3094 TypeArguments& test_targ_1 = TypeArguments::Handle(); | 3094 TypeArguments& test_targ_1 = TypeArguments::Handle(); |
| 3095 Bool& test_result = Bool::Handle(); | 3095 Bool& test_result = Bool::Handle(); |
| 3096 cache.GetCheck(0, &test_class_id_or_fun, &test_targ_0, &test_targ_1, | 3096 cache.GetCheck(0, &test_class_id_or_fun, &test_targ_0, &test_targ_1, |
| 3097 &test_result); | 3097 &test_result); |
| 3098 EXPECT_EQ(class_id_or_fun.raw(), test_class_id_or_fun.raw()); | 3098 EXPECT_EQ(class_id_or_fun.raw(), test_class_id_or_fun.raw()); |
| 3099 EXPECT_EQ(targ_0.raw(), test_targ_0.raw()); | 3099 EXPECT_EQ(targ_0.raw(), test_targ_0.raw()); |
| 3100 EXPECT_EQ(targ_1.raw(), test_targ_1.raw()); | 3100 EXPECT_EQ(targ_1.raw(), test_targ_1.raw()); |
| 3101 EXPECT_EQ(Bool::True().raw(), test_result.raw()); | 3101 EXPECT_EQ(Bool::True().raw(), test_result.raw()); |
| 3102 } | 3102 } |
| 3103 | 3103 |
| 3104 | 3104 |
| 3105 VM_TEST_CASE(FieldTests) { | 3105 ISOLATE_UNIT_TEST_CASE(FieldTests) { |
| 3106 const String& f = String::Handle(String::New("oneField")); | 3106 const String& f = String::Handle(String::New("oneField")); |
| 3107 const String& getter_f = String::Handle(Field::GetterName(f)); | 3107 const String& getter_f = String::Handle(Field::GetterName(f)); |
| 3108 const String& setter_f = String::Handle(Field::SetterName(f)); | 3108 const String& setter_f = String::Handle(Field::SetterName(f)); |
| 3109 EXPECT(!Field::IsGetterName(f)); | 3109 EXPECT(!Field::IsGetterName(f)); |
| 3110 EXPECT(!Field::IsSetterName(f)); | 3110 EXPECT(!Field::IsSetterName(f)); |
| 3111 EXPECT(Field::IsGetterName(getter_f)); | 3111 EXPECT(Field::IsGetterName(getter_f)); |
| 3112 EXPECT(!Field::IsSetterName(getter_f)); | 3112 EXPECT(!Field::IsSetterName(getter_f)); |
| 3113 EXPECT(!Field::IsGetterName(setter_f)); | 3113 EXPECT(!Field::IsGetterName(setter_f)); |
| 3114 EXPECT(Field::IsSetterName(setter_f)); | 3114 EXPECT(Field::IsSetterName(setter_f)); |
| 3115 EXPECT_STREQ(f.ToCString(), | 3115 EXPECT_STREQ(f.ToCString(), |
| 3116 String::Handle(Field::NameFromGetter(getter_f)).ToCString()); | 3116 String::Handle(Field::NameFromGetter(getter_f)).ToCString()); |
| 3117 EXPECT_STREQ(f.ToCString(), | 3117 EXPECT_STREQ(f.ToCString(), |
| 3118 String::Handle(Field::NameFromSetter(setter_f)).ToCString()); | 3118 String::Handle(Field::NameFromSetter(setter_f)).ToCString()); |
| 3119 } | 3119 } |
| 3120 | 3120 |
| 3121 | 3121 |
| 3122 // Expose helper function from object.cc for testing. | 3122 // Expose helper function from object.cc for testing. |
| 3123 bool EqualsIgnoringPrivate(const String& name, const String& private_name); | 3123 bool EqualsIgnoringPrivate(const String& name, const String& private_name); |
| 3124 | 3124 |
| 3125 | 3125 |
| 3126 VM_TEST_CASE(EqualsIgnoringPrivate) { | 3126 ISOLATE_UNIT_TEST_CASE(EqualsIgnoringPrivate) { |
| 3127 String& mangled_name = String::Handle(); | 3127 String& mangled_name = String::Handle(); |
| 3128 String& bare_name = String::Handle(); | 3128 String& bare_name = String::Handle(); |
| 3129 | 3129 |
| 3130 // Simple matches. | 3130 // Simple matches. |
| 3131 mangled_name = OneByteString::New("foo"); | 3131 mangled_name = OneByteString::New("foo"); |
| 3132 bare_name = OneByteString::New("foo"); | 3132 bare_name = OneByteString::New("foo"); |
| 3133 EXPECT(String::EqualsIgnoringPrivateKey(mangled_name, bare_name)); | 3133 EXPECT(String::EqualsIgnoringPrivateKey(mangled_name, bare_name)); |
| 3134 | 3134 |
| 3135 mangled_name = OneByteString::New("foo."); | 3135 mangled_name = OneByteString::New("foo."); |
| 3136 bare_name = OneByteString::New("foo."); | 3136 bare_name = OneByteString::New("foo."); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3249 // str1 - ExternalOneByteString, str2 - OneByteString. | 3249 // str1 - ExternalOneByteString, str2 - OneByteString. |
| 3250 EXPECT(String::EqualsIgnoringPrivateKey(ext_mangled_name, bare_name)); | 3250 EXPECT(String::EqualsIgnoringPrivateKey(ext_mangled_name, bare_name)); |
| 3251 | 3251 |
| 3252 // str1 - ExternalOneByteString, str2 - ExternalOneByteString. | 3252 // str1 - ExternalOneByteString, str2 - ExternalOneByteString. |
| 3253 EXPECT(String::EqualsIgnoringPrivateKey(ext_mangled_name, ext_bare_name)); | 3253 EXPECT(String::EqualsIgnoringPrivateKey(ext_mangled_name, ext_bare_name)); |
| 3254 EXPECT( | 3254 EXPECT( |
| 3255 !String::EqualsIgnoringPrivateKey(ext_mangled_name, ext_bad_bare_name)); | 3255 !String::EqualsIgnoringPrivateKey(ext_mangled_name, ext_bad_bare_name)); |
| 3256 } | 3256 } |
| 3257 | 3257 |
| 3258 | 3258 |
| 3259 VM_TEST_CASE(ArrayNew_Overflow_Crash) { | 3259 ISOLATE_UNIT_TEST_CASE(ArrayNew_Overflow_Crash) { |
| 3260 Array::Handle(Array::New(Array::kMaxElements + 1)); | 3260 Array::Handle(Array::New(Array::kMaxElements + 1)); |
| 3261 } | 3261 } |
| 3262 | 3262 |
| 3263 | 3263 |
| 3264 TEST_CASE(StackTraceFormat) { | 3264 TEST_CASE(StackTraceFormat) { |
| 3265 const char* kScriptChars = | 3265 const char* kScriptChars = |
| 3266 "void baz() {\n" | 3266 "void baz() {\n" |
| 3267 " throw 'MyException';\n" | 3267 " throw 'MyException';\n" |
| 3268 "}\n" | 3268 "}\n" |
| 3269 "\n" | 3269 "\n" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3314 "#4 MyClass.field (test-lib:25:5)\n" | 3314 "#4 MyClass.field (test-lib:25:5)\n" |
| 3315 "#5 MyClass.foo.fooHelper (test-lib:30:7)\n" | 3315 "#5 MyClass.foo.fooHelper (test-lib:30:7)\n" |
| 3316 "#6 MyClass.foo (test-lib:32:14)\n" | 3316 "#6 MyClass.foo (test-lib:32:14)\n" |
| 3317 "#7 MyClass.MyClass.<anonymous closure> (test-lib:21:12)\n" | 3317 "#7 MyClass.MyClass.<anonymous closure> (test-lib:21:12)\n" |
| 3318 "#8 MyClass.MyClass (test-lib:21:18)\n" | 3318 "#8 MyClass.MyClass (test-lib:21:18)\n" |
| 3319 "#9 main.<anonymous closure> (test-lib:37:14)\n" | 3319 "#9 main.<anonymous closure> (test-lib:37:14)\n" |
| 3320 "#10 main (test-lib:37:24)"); | 3320 "#10 main (test-lib:37:24)"); |
| 3321 } | 3321 } |
| 3322 | 3322 |
| 3323 | 3323 |
| 3324 VM_TEST_CASE(WeakProperty_PreserveCrossGen) { | 3324 ISOLATE_UNIT_TEST_CASE(WeakProperty_PreserveCrossGen) { |
| 3325 Isolate* isolate = Isolate::Current(); | 3325 Isolate* isolate = Isolate::Current(); |
| 3326 WeakProperty& weak = WeakProperty::Handle(); | 3326 WeakProperty& weak = WeakProperty::Handle(); |
| 3327 { | 3327 { |
| 3328 // Weak property and value in new. Key in old. | 3328 // Weak property and value in new. Key in old. |
| 3329 HANDLESCOPE(thread); | 3329 HANDLESCOPE(thread); |
| 3330 String& key = String::Handle(); | 3330 String& key = String::Handle(); |
| 3331 key ^= OneByteString::New("key", Heap::kOld); | 3331 key ^= OneByteString::New("key", Heap::kOld); |
| 3332 String& value = String::Handle(); | 3332 String& value = String::Handle(); |
| 3333 value ^= OneByteString::New("value", Heap::kNew); | 3333 value ^= OneByteString::New("value", Heap::kNew); |
| 3334 weak ^= WeakProperty::New(Heap::kNew); | 3334 weak ^= WeakProperty::New(Heap::kNew); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3426 value ^= OneByteString::null(); | 3426 value ^= OneByteString::null(); |
| 3427 } | 3427 } |
| 3428 isolate->heap()->CollectAllGarbage(); | 3428 isolate->heap()->CollectAllGarbage(); |
| 3429 // Weak property key and value should survive due to cross-generation | 3429 // Weak property key and value should survive due to cross-generation |
| 3430 // pointers. | 3430 // pointers. |
| 3431 EXPECT(weak.key() != Object::null()); | 3431 EXPECT(weak.key() != Object::null()); |
| 3432 EXPECT(weak.value() != Object::null()); | 3432 EXPECT(weak.value() != Object::null()); |
| 3433 } | 3433 } |
| 3434 | 3434 |
| 3435 | 3435 |
| 3436 VM_TEST_CASE(WeakProperty_PreserveRecurse) { | 3436 ISOLATE_UNIT_TEST_CASE(WeakProperty_PreserveRecurse) { |
| 3437 // This used to end in an infinite recursion. Caused by scavenging the weak | 3437 // This used to end in an infinite recursion. Caused by scavenging the weak |
| 3438 // property before scavenging the key. | 3438 // property before scavenging the key. |
| 3439 Isolate* isolate = Isolate::Current(); | 3439 Isolate* isolate = Isolate::Current(); |
| 3440 WeakProperty& weak = WeakProperty::Handle(); | 3440 WeakProperty& weak = WeakProperty::Handle(); |
| 3441 Array& arr = Array::Handle(Array::New(1)); | 3441 Array& arr = Array::Handle(Array::New(1)); |
| 3442 { | 3442 { |
| 3443 HANDLESCOPE(thread); | 3443 HANDLESCOPE(thread); |
| 3444 String& key = String::Handle(); | 3444 String& key = String::Handle(); |
| 3445 key ^= OneByteString::New("key"); | 3445 key ^= OneByteString::New("key"); |
| 3446 arr.SetAt(0, key); | 3446 arr.SetAt(0, key); |
| 3447 String& value = String::Handle(); | 3447 String& value = String::Handle(); |
| 3448 value ^= OneByteString::New("value"); | 3448 value ^= OneByteString::New("value"); |
| 3449 weak ^= WeakProperty::New(); | 3449 weak ^= WeakProperty::New(); |
| 3450 weak.set_key(key); | 3450 weak.set_key(key); |
| 3451 weak.set_value(value); | 3451 weak.set_value(value); |
| 3452 } | 3452 } |
| 3453 isolate->heap()->CollectAllGarbage(); | 3453 isolate->heap()->CollectAllGarbage(); |
| 3454 EXPECT(weak.key() != Object::null()); | 3454 EXPECT(weak.key() != Object::null()); |
| 3455 EXPECT(weak.value() != Object::null()); | 3455 EXPECT(weak.value() != Object::null()); |
| 3456 } | 3456 } |
| 3457 | 3457 |
| 3458 | 3458 |
| 3459 VM_TEST_CASE(WeakProperty_PreserveOne_NewSpace) { | 3459 ISOLATE_UNIT_TEST_CASE(WeakProperty_PreserveOne_NewSpace) { |
| 3460 Isolate* isolate = Isolate::Current(); | 3460 Isolate* isolate = Isolate::Current(); |
| 3461 WeakProperty& weak = WeakProperty::Handle(); | 3461 WeakProperty& weak = WeakProperty::Handle(); |
| 3462 String& key = String::Handle(); | 3462 String& key = String::Handle(); |
| 3463 key ^= OneByteString::New("key"); | 3463 key ^= OneByteString::New("key"); |
| 3464 { | 3464 { |
| 3465 HANDLESCOPE(thread); | 3465 HANDLESCOPE(thread); |
| 3466 String& value = String::Handle(); | 3466 String& value = String::Handle(); |
| 3467 value ^= OneByteString::New("value"); | 3467 value ^= OneByteString::New("value"); |
| 3468 weak ^= WeakProperty::New(); | 3468 weak ^= WeakProperty::New(); |
| 3469 weak.set_key(key); | 3469 weak.set_key(key); |
| 3470 weak.set_value(value); | 3470 weak.set_value(value); |
| 3471 } | 3471 } |
| 3472 isolate->heap()->CollectAllGarbage(); | 3472 isolate->heap()->CollectAllGarbage(); |
| 3473 EXPECT(weak.key() != Object::null()); | 3473 EXPECT(weak.key() != Object::null()); |
| 3474 EXPECT(weak.value() != Object::null()); | 3474 EXPECT(weak.value() != Object::null()); |
| 3475 } | 3475 } |
| 3476 | 3476 |
| 3477 | 3477 |
| 3478 VM_TEST_CASE(WeakProperty_PreserveTwo_NewSpace) { | 3478 ISOLATE_UNIT_TEST_CASE(WeakProperty_PreserveTwo_NewSpace) { |
| 3479 Isolate* isolate = Isolate::Current(); | 3479 Isolate* isolate = Isolate::Current(); |
| 3480 WeakProperty& weak1 = WeakProperty::Handle(); | 3480 WeakProperty& weak1 = WeakProperty::Handle(); |
| 3481 String& key1 = String::Handle(); | 3481 String& key1 = String::Handle(); |
| 3482 key1 ^= OneByteString::New("key1"); | 3482 key1 ^= OneByteString::New("key1"); |
| 3483 WeakProperty& weak2 = WeakProperty::Handle(); | 3483 WeakProperty& weak2 = WeakProperty::Handle(); |
| 3484 String& key2 = String::Handle(); | 3484 String& key2 = String::Handle(); |
| 3485 key2 ^= OneByteString::New("key2"); | 3485 key2 ^= OneByteString::New("key2"); |
| 3486 { | 3486 { |
| 3487 HANDLESCOPE(thread); | 3487 HANDLESCOPE(thread); |
| 3488 String& value1 = String::Handle(); | 3488 String& value1 = String::Handle(); |
| 3489 value1 ^= OneByteString::New("value1"); | 3489 value1 ^= OneByteString::New("value1"); |
| 3490 weak1 ^= WeakProperty::New(); | 3490 weak1 ^= WeakProperty::New(); |
| 3491 weak1.set_key(key1); | 3491 weak1.set_key(key1); |
| 3492 weak1.set_value(value1); | 3492 weak1.set_value(value1); |
| 3493 String& value2 = String::Handle(); | 3493 String& value2 = String::Handle(); |
| 3494 value2 ^= OneByteString::New("value2"); | 3494 value2 ^= OneByteString::New("value2"); |
| 3495 weak2 ^= WeakProperty::New(); | 3495 weak2 ^= WeakProperty::New(); |
| 3496 weak2.set_key(key2); | 3496 weak2.set_key(key2); |
| 3497 weak2.set_value(value2); | 3497 weak2.set_value(value2); |
| 3498 } | 3498 } |
| 3499 isolate->heap()->CollectAllGarbage(); | 3499 isolate->heap()->CollectAllGarbage(); |
| 3500 EXPECT(weak1.key() != Object::null()); | 3500 EXPECT(weak1.key() != Object::null()); |
| 3501 EXPECT(weak1.value() != Object::null()); | 3501 EXPECT(weak1.value() != Object::null()); |
| 3502 EXPECT(weak2.key() != Object::null()); | 3502 EXPECT(weak2.key() != Object::null()); |
| 3503 EXPECT(weak2.value() != Object::null()); | 3503 EXPECT(weak2.value() != Object::null()); |
| 3504 } | 3504 } |
| 3505 | 3505 |
| 3506 | 3506 |
| 3507 VM_TEST_CASE(WeakProperty_PreserveTwoShared_NewSpace) { | 3507 ISOLATE_UNIT_TEST_CASE(WeakProperty_PreserveTwoShared_NewSpace) { |
| 3508 Isolate* isolate = Isolate::Current(); | 3508 Isolate* isolate = Isolate::Current(); |
| 3509 WeakProperty& weak1 = WeakProperty::Handle(); | 3509 WeakProperty& weak1 = WeakProperty::Handle(); |
| 3510 WeakProperty& weak2 = WeakProperty::Handle(); | 3510 WeakProperty& weak2 = WeakProperty::Handle(); |
| 3511 String& key = String::Handle(); | 3511 String& key = String::Handle(); |
| 3512 key ^= OneByteString::New("key"); | 3512 key ^= OneByteString::New("key"); |
| 3513 { | 3513 { |
| 3514 HANDLESCOPE(thread); | 3514 HANDLESCOPE(thread); |
| 3515 String& value1 = String::Handle(); | 3515 String& value1 = String::Handle(); |
| 3516 value1 ^= OneByteString::New("value1"); | 3516 value1 ^= OneByteString::New("value1"); |
| 3517 weak1 ^= WeakProperty::New(); | 3517 weak1 ^= WeakProperty::New(); |
| 3518 weak1.set_key(key); | 3518 weak1.set_key(key); |
| 3519 weak1.set_value(value1); | 3519 weak1.set_value(value1); |
| 3520 String& value2 = String::Handle(); | 3520 String& value2 = String::Handle(); |
| 3521 value2 ^= OneByteString::New("value2"); | 3521 value2 ^= OneByteString::New("value2"); |
| 3522 weak2 ^= WeakProperty::New(); | 3522 weak2 ^= WeakProperty::New(); |
| 3523 weak2.set_key(key); | 3523 weak2.set_key(key); |
| 3524 weak2.set_value(value2); | 3524 weak2.set_value(value2); |
| 3525 } | 3525 } |
| 3526 isolate->heap()->CollectAllGarbage(); | 3526 isolate->heap()->CollectAllGarbage(); |
| 3527 EXPECT(weak1.key() != Object::null()); | 3527 EXPECT(weak1.key() != Object::null()); |
| 3528 EXPECT(weak1.value() != Object::null()); | 3528 EXPECT(weak1.value() != Object::null()); |
| 3529 EXPECT(weak2.key() != Object::null()); | 3529 EXPECT(weak2.key() != Object::null()); |
| 3530 EXPECT(weak2.value() != Object::null()); | 3530 EXPECT(weak2.value() != Object::null()); |
| 3531 } | 3531 } |
| 3532 | 3532 |
| 3533 | 3533 |
| 3534 VM_TEST_CASE(WeakProperty_PreserveOne_OldSpace) { | 3534 ISOLATE_UNIT_TEST_CASE(WeakProperty_PreserveOne_OldSpace) { |
| 3535 Isolate* isolate = Isolate::Current(); | 3535 Isolate* isolate = Isolate::Current(); |
| 3536 WeakProperty& weak = WeakProperty::Handle(); | 3536 WeakProperty& weak = WeakProperty::Handle(); |
| 3537 String& key = String::Handle(); | 3537 String& key = String::Handle(); |
| 3538 key ^= OneByteString::New("key", Heap::kOld); | 3538 key ^= OneByteString::New("key", Heap::kOld); |
| 3539 { | 3539 { |
| 3540 HANDLESCOPE(thread); | 3540 HANDLESCOPE(thread); |
| 3541 String& value = String::Handle(); | 3541 String& value = String::Handle(); |
| 3542 value ^= OneByteString::New("value", Heap::kOld); | 3542 value ^= OneByteString::New("value", Heap::kOld); |
| 3543 weak ^= WeakProperty::New(Heap::kOld); | 3543 weak ^= WeakProperty::New(Heap::kOld); |
| 3544 weak.set_key(key); | 3544 weak.set_key(key); |
| 3545 weak.set_value(value); | 3545 weak.set_value(value); |
| 3546 } | 3546 } |
| 3547 isolate->heap()->CollectAllGarbage(); | 3547 isolate->heap()->CollectAllGarbage(); |
| 3548 EXPECT(weak.key() != Object::null()); | 3548 EXPECT(weak.key() != Object::null()); |
| 3549 EXPECT(weak.value() != Object::null()); | 3549 EXPECT(weak.value() != Object::null()); |
| 3550 } | 3550 } |
| 3551 | 3551 |
| 3552 | 3552 |
| 3553 VM_TEST_CASE(WeakProperty_PreserveTwo_OldSpace) { | 3553 ISOLATE_UNIT_TEST_CASE(WeakProperty_PreserveTwo_OldSpace) { |
| 3554 Isolate* isolate = Isolate::Current(); | 3554 Isolate* isolate = Isolate::Current(); |
| 3555 WeakProperty& weak1 = WeakProperty::Handle(); | 3555 WeakProperty& weak1 = WeakProperty::Handle(); |
| 3556 String& key1 = String::Handle(); | 3556 String& key1 = String::Handle(); |
| 3557 key1 ^= OneByteString::New("key1", Heap::kOld); | 3557 key1 ^= OneByteString::New("key1", Heap::kOld); |
| 3558 WeakProperty& weak2 = WeakProperty::Handle(); | 3558 WeakProperty& weak2 = WeakProperty::Handle(); |
| 3559 String& key2 = String::Handle(); | 3559 String& key2 = String::Handle(); |
| 3560 key2 ^= OneByteString::New("key2", Heap::kOld); | 3560 key2 ^= OneByteString::New("key2", Heap::kOld); |
| 3561 { | 3561 { |
| 3562 HANDLESCOPE(thread); | 3562 HANDLESCOPE(thread); |
| 3563 String& value1 = String::Handle(); | 3563 String& value1 = String::Handle(); |
| 3564 value1 ^= OneByteString::New("value1", Heap::kOld); | 3564 value1 ^= OneByteString::New("value1", Heap::kOld); |
| 3565 weak1 ^= WeakProperty::New(Heap::kOld); | 3565 weak1 ^= WeakProperty::New(Heap::kOld); |
| 3566 weak1.set_key(key1); | 3566 weak1.set_key(key1); |
| 3567 weak1.set_value(value1); | 3567 weak1.set_value(value1); |
| 3568 String& value2 = String::Handle(); | 3568 String& value2 = String::Handle(); |
| 3569 value2 ^= OneByteString::New("value2", Heap::kOld); | 3569 value2 ^= OneByteString::New("value2", Heap::kOld); |
| 3570 weak2 ^= WeakProperty::New(Heap::kOld); | 3570 weak2 ^= WeakProperty::New(Heap::kOld); |
| 3571 weak2.set_key(key2); | 3571 weak2.set_key(key2); |
| 3572 weak2.set_value(value2); | 3572 weak2.set_value(value2); |
| 3573 } | 3573 } |
| 3574 isolate->heap()->CollectAllGarbage(); | 3574 isolate->heap()->CollectAllGarbage(); |
| 3575 EXPECT(weak1.key() != Object::null()); | 3575 EXPECT(weak1.key() != Object::null()); |
| 3576 EXPECT(weak1.value() != Object::null()); | 3576 EXPECT(weak1.value() != Object::null()); |
| 3577 EXPECT(weak2.key() != Object::null()); | 3577 EXPECT(weak2.key() != Object::null()); |
| 3578 EXPECT(weak2.value() != Object::null()); | 3578 EXPECT(weak2.value() != Object::null()); |
| 3579 } | 3579 } |
| 3580 | 3580 |
| 3581 | 3581 |
| 3582 VM_TEST_CASE(WeakProperty_PreserveTwoShared_OldSpace) { | 3582 ISOLATE_UNIT_TEST_CASE(WeakProperty_PreserveTwoShared_OldSpace) { |
| 3583 Isolate* isolate = Isolate::Current(); | 3583 Isolate* isolate = Isolate::Current(); |
| 3584 WeakProperty& weak1 = WeakProperty::Handle(); | 3584 WeakProperty& weak1 = WeakProperty::Handle(); |
| 3585 WeakProperty& weak2 = WeakProperty::Handle(); | 3585 WeakProperty& weak2 = WeakProperty::Handle(); |
| 3586 String& key = String::Handle(); | 3586 String& key = String::Handle(); |
| 3587 key ^= OneByteString::New("key", Heap::kOld); | 3587 key ^= OneByteString::New("key", Heap::kOld); |
| 3588 { | 3588 { |
| 3589 HANDLESCOPE(thread); | 3589 HANDLESCOPE(thread); |
| 3590 String& value1 = String::Handle(); | 3590 String& value1 = String::Handle(); |
| 3591 value1 ^= OneByteString::New("value1", Heap::kOld); | 3591 value1 ^= OneByteString::New("value1", Heap::kOld); |
| 3592 weak1 ^= WeakProperty::New(Heap::kOld); | 3592 weak1 ^= WeakProperty::New(Heap::kOld); |
| 3593 weak1.set_key(key); | 3593 weak1.set_key(key); |
| 3594 weak1.set_value(value1); | 3594 weak1.set_value(value1); |
| 3595 String& value2 = String::Handle(); | 3595 String& value2 = String::Handle(); |
| 3596 value2 ^= OneByteString::New("value2", Heap::kOld); | 3596 value2 ^= OneByteString::New("value2", Heap::kOld); |
| 3597 weak2 ^= WeakProperty::New(Heap::kOld); | 3597 weak2 ^= WeakProperty::New(Heap::kOld); |
| 3598 weak2.set_key(key); | 3598 weak2.set_key(key); |
| 3599 weak2.set_value(value2); | 3599 weak2.set_value(value2); |
| 3600 } | 3600 } |
| 3601 isolate->heap()->CollectAllGarbage(); | 3601 isolate->heap()->CollectAllGarbage(); |
| 3602 EXPECT(weak1.key() != Object::null()); | 3602 EXPECT(weak1.key() != Object::null()); |
| 3603 EXPECT(weak1.value() != Object::null()); | 3603 EXPECT(weak1.value() != Object::null()); |
| 3604 EXPECT(weak2.key() != Object::null()); | 3604 EXPECT(weak2.key() != Object::null()); |
| 3605 EXPECT(weak2.value() != Object::null()); | 3605 EXPECT(weak2.value() != Object::null()); |
| 3606 } | 3606 } |
| 3607 | 3607 |
| 3608 | 3608 |
| 3609 VM_TEST_CASE(WeakProperty_ClearOne_NewSpace) { | 3609 ISOLATE_UNIT_TEST_CASE(WeakProperty_ClearOne_NewSpace) { |
| 3610 Isolate* isolate = Isolate::Current(); | 3610 Isolate* isolate = Isolate::Current(); |
| 3611 WeakProperty& weak = WeakProperty::Handle(); | 3611 WeakProperty& weak = WeakProperty::Handle(); |
| 3612 { | 3612 { |
| 3613 HANDLESCOPE(thread); | 3613 HANDLESCOPE(thread); |
| 3614 String& key = String::Handle(); | 3614 String& key = String::Handle(); |
| 3615 key ^= OneByteString::New("key"); | 3615 key ^= OneByteString::New("key"); |
| 3616 String& value = String::Handle(); | 3616 String& value = String::Handle(); |
| 3617 value ^= OneByteString::New("value"); | 3617 value ^= OneByteString::New("value"); |
| 3618 weak ^= WeakProperty::New(); | 3618 weak ^= WeakProperty::New(); |
| 3619 weak.set_key(key); | 3619 weak.set_key(key); |
| 3620 weak.set_value(value); | 3620 weak.set_value(value); |
| 3621 key ^= OneByteString::null(); | 3621 key ^= OneByteString::null(); |
| 3622 value ^= OneByteString::null(); | 3622 value ^= OneByteString::null(); |
| 3623 } | 3623 } |
| 3624 isolate->heap()->CollectAllGarbage(); | 3624 isolate->heap()->CollectAllGarbage(); |
| 3625 EXPECT(weak.key() == Object::null()); | 3625 EXPECT(weak.key() == Object::null()); |
| 3626 EXPECT(weak.value() == Object::null()); | 3626 EXPECT(weak.value() == Object::null()); |
| 3627 } | 3627 } |
| 3628 | 3628 |
| 3629 | 3629 |
| 3630 VM_TEST_CASE(WeakProperty_ClearTwoShared_NewSpace) { | 3630 ISOLATE_UNIT_TEST_CASE(WeakProperty_ClearTwoShared_NewSpace) { |
| 3631 Isolate* isolate = Isolate::Current(); | 3631 Isolate* isolate = Isolate::Current(); |
| 3632 WeakProperty& weak1 = WeakProperty::Handle(); | 3632 WeakProperty& weak1 = WeakProperty::Handle(); |
| 3633 WeakProperty& weak2 = WeakProperty::Handle(); | 3633 WeakProperty& weak2 = WeakProperty::Handle(); |
| 3634 { | 3634 { |
| 3635 HANDLESCOPE(thread); | 3635 HANDLESCOPE(thread); |
| 3636 String& key = String::Handle(); | 3636 String& key = String::Handle(); |
| 3637 key ^= OneByteString::New("key"); | 3637 key ^= OneByteString::New("key"); |
| 3638 String& value1 = String::Handle(); | 3638 String& value1 = String::Handle(); |
| 3639 value1 ^= OneByteString::New("value1"); | 3639 value1 ^= OneByteString::New("value1"); |
| 3640 weak1 ^= WeakProperty::New(); | 3640 weak1 ^= WeakProperty::New(); |
| 3641 weak1.set_key(key); | 3641 weak1.set_key(key); |
| 3642 weak1.set_value(value1); | 3642 weak1.set_value(value1); |
| 3643 String& value2 = String::Handle(); | 3643 String& value2 = String::Handle(); |
| 3644 value2 ^= OneByteString::New("value2"); | 3644 value2 ^= OneByteString::New("value2"); |
| 3645 weak2 ^= WeakProperty::New(); | 3645 weak2 ^= WeakProperty::New(); |
| 3646 weak2.set_key(key); | 3646 weak2.set_key(key); |
| 3647 weak2.set_value(value2); | 3647 weak2.set_value(value2); |
| 3648 } | 3648 } |
| 3649 isolate->heap()->CollectAllGarbage(); | 3649 isolate->heap()->CollectAllGarbage(); |
| 3650 EXPECT(weak1.key() == Object::null()); | 3650 EXPECT(weak1.key() == Object::null()); |
| 3651 EXPECT(weak1.value() == Object::null()); | 3651 EXPECT(weak1.value() == Object::null()); |
| 3652 EXPECT(weak2.key() == Object::null()); | 3652 EXPECT(weak2.key() == Object::null()); |
| 3653 EXPECT(weak2.value() == Object::null()); | 3653 EXPECT(weak2.value() == Object::null()); |
| 3654 } | 3654 } |
| 3655 | 3655 |
| 3656 | 3656 |
| 3657 VM_TEST_CASE(WeakProperty_ClearOne_OldSpace) { | 3657 ISOLATE_UNIT_TEST_CASE(WeakProperty_ClearOne_OldSpace) { |
| 3658 Isolate* isolate = Isolate::Current(); | 3658 Isolate* isolate = Isolate::Current(); |
| 3659 WeakProperty& weak = WeakProperty::Handle(); | 3659 WeakProperty& weak = WeakProperty::Handle(); |
| 3660 { | 3660 { |
| 3661 HANDLESCOPE(thread); | 3661 HANDLESCOPE(thread); |
| 3662 String& key = String::Handle(); | 3662 String& key = String::Handle(); |
| 3663 key ^= OneByteString::New("key", Heap::kOld); | 3663 key ^= OneByteString::New("key", Heap::kOld); |
| 3664 String& value = String::Handle(); | 3664 String& value = String::Handle(); |
| 3665 value ^= OneByteString::New("value", Heap::kOld); | 3665 value ^= OneByteString::New("value", Heap::kOld); |
| 3666 weak ^= WeakProperty::New(Heap::kOld); | 3666 weak ^= WeakProperty::New(Heap::kOld); |
| 3667 weak.set_key(key); | 3667 weak.set_key(key); |
| 3668 weak.set_value(value); | 3668 weak.set_value(value); |
| 3669 key ^= OneByteString::null(); | 3669 key ^= OneByteString::null(); |
| 3670 value ^= OneByteString::null(); | 3670 value ^= OneByteString::null(); |
| 3671 } | 3671 } |
| 3672 isolate->heap()->CollectAllGarbage(); | 3672 isolate->heap()->CollectAllGarbage(); |
| 3673 EXPECT(weak.key() == Object::null()); | 3673 EXPECT(weak.key() == Object::null()); |
| 3674 EXPECT(weak.value() == Object::null()); | 3674 EXPECT(weak.value() == Object::null()); |
| 3675 } | 3675 } |
| 3676 | 3676 |
| 3677 | 3677 |
| 3678 VM_TEST_CASE(WeakProperty_ClearTwoShared_OldSpace) { | 3678 ISOLATE_UNIT_TEST_CASE(WeakProperty_ClearTwoShared_OldSpace) { |
| 3679 Isolate* isolate = Isolate::Current(); | 3679 Isolate* isolate = Isolate::Current(); |
| 3680 WeakProperty& weak1 = WeakProperty::Handle(); | 3680 WeakProperty& weak1 = WeakProperty::Handle(); |
| 3681 WeakProperty& weak2 = WeakProperty::Handle(); | 3681 WeakProperty& weak2 = WeakProperty::Handle(); |
| 3682 { | 3682 { |
| 3683 HANDLESCOPE(thread); | 3683 HANDLESCOPE(thread); |
| 3684 String& key = String::Handle(); | 3684 String& key = String::Handle(); |
| 3685 key ^= OneByteString::New("key", Heap::kOld); | 3685 key ^= OneByteString::New("key", Heap::kOld); |
| 3686 String& value1 = String::Handle(); | 3686 String& value1 = String::Handle(); |
| 3687 value1 ^= OneByteString::New("value1"); | 3687 value1 ^= OneByteString::New("value1"); |
| 3688 weak1 ^= WeakProperty::New(Heap::kOld); | 3688 weak1 ^= WeakProperty::New(Heap::kOld); |
| 3689 weak1.set_key(key); | 3689 weak1.set_key(key); |
| 3690 weak1.set_value(value1); | 3690 weak1.set_value(value1); |
| 3691 String& value2 = String::Handle(); | 3691 String& value2 = String::Handle(); |
| 3692 value2 ^= OneByteString::New("value2", Heap::kOld); | 3692 value2 ^= OneByteString::New("value2", Heap::kOld); |
| 3693 weak2 ^= WeakProperty::New(Heap::kOld); | 3693 weak2 ^= WeakProperty::New(Heap::kOld); |
| 3694 weak2.set_key(key); | 3694 weak2.set_key(key); |
| 3695 weak2.set_value(value2); | 3695 weak2.set_value(value2); |
| 3696 } | 3696 } |
| 3697 isolate->heap()->CollectAllGarbage(); | 3697 isolate->heap()->CollectAllGarbage(); |
| 3698 EXPECT(weak1.key() == Object::null()); | 3698 EXPECT(weak1.key() == Object::null()); |
| 3699 EXPECT(weak1.value() == Object::null()); | 3699 EXPECT(weak1.value() == Object::null()); |
| 3700 EXPECT(weak2.key() == Object::null()); | 3700 EXPECT(weak2.key() == Object::null()); |
| 3701 EXPECT(weak2.value() == Object::null()); | 3701 EXPECT(weak2.value() == Object::null()); |
| 3702 } | 3702 } |
| 3703 | 3703 |
| 3704 | 3704 |
| 3705 VM_TEST_CASE(MirrorReference) { | 3705 ISOLATE_UNIT_TEST_CASE(MirrorReference) { |
| 3706 const MirrorReference& reference = | 3706 const MirrorReference& reference = |
| 3707 MirrorReference::Handle(MirrorReference::New(Object::Handle())); | 3707 MirrorReference::Handle(MirrorReference::New(Object::Handle())); |
| 3708 Object& initial_referent = Object::Handle(reference.referent()); | 3708 Object& initial_referent = Object::Handle(reference.referent()); |
| 3709 EXPECT(initial_referent.IsNull()); | 3709 EXPECT(initial_referent.IsNull()); |
| 3710 | 3710 |
| 3711 Library& library = Library::Handle(Library::CoreLibrary()); | 3711 Library& library = Library::Handle(Library::CoreLibrary()); |
| 3712 EXPECT(!library.IsNull()); | 3712 EXPECT(!library.IsNull()); |
| 3713 EXPECT(library.IsLibrary()); | 3713 EXPECT(library.IsLibrary()); |
| 3714 reference.set_referent(library); | 3714 reference.set_referent(library); |
| 3715 const Object& returned_referent = Object::Handle(reference.referent()); | 3715 const Object& returned_referent = Object::Handle(reference.referent()); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3753 | 3753 |
| 3754 | 3754 |
| 3755 static RawClass* GetClass(const Library& lib, const char* name) { | 3755 static RawClass* GetClass(const Library& lib, const char* name) { |
| 3756 const Class& cls = Class::Handle( | 3756 const Class& cls = Class::Handle( |
| 3757 lib.LookupClass(String::Handle(Symbols::New(Thread::Current(), name)))); | 3757 lib.LookupClass(String::Handle(Symbols::New(Thread::Current(), name)))); |
| 3758 EXPECT(!cls.IsNull()); // No ambiguity error expected. | 3758 EXPECT(!cls.IsNull()); // No ambiguity error expected. |
| 3759 return cls.raw(); | 3759 return cls.raw(); |
| 3760 } | 3760 } |
| 3761 | 3761 |
| 3762 | 3762 |
| 3763 VM_TEST_CASE(FindClosureIndex) { | 3763 ISOLATE_UNIT_TEST_CASE(FindClosureIndex) { |
| 3764 // Allocate the class first. | 3764 // Allocate the class first. |
| 3765 const String& class_name = String::Handle(Symbols::New(thread, "MyClass")); | 3765 const String& class_name = String::Handle(Symbols::New(thread, "MyClass")); |
| 3766 const Script& script = Script::Handle(); | 3766 const Script& script = Script::Handle(); |
| 3767 const Class& cls = Class::Handle(CreateDummyClass(class_name, script)); | 3767 const Class& cls = Class::Handle(CreateDummyClass(class_name, script)); |
| 3768 const Array& functions = Array::Handle(Array::New(1)); | 3768 const Array& functions = Array::Handle(Array::New(1)); |
| 3769 const Isolate* iso = Isolate::Current(); | 3769 const Isolate* iso = Isolate::Current(); |
| 3770 | 3770 |
| 3771 Function& parent = Function::Handle(); | 3771 Function& parent = Function::Handle(); |
| 3772 const String& parent_name = String::Handle(Symbols::New(thread, "foo_papa")); | 3772 const String& parent_name = String::Handle(Symbols::New(thread, "foo_papa")); |
| 3773 parent = | 3773 parent = |
| (...skipping 17 matching lines...) Expand all Loading... |
| 3791 EXPECT_EQ(bad_closure_index, -1); | 3791 EXPECT_EQ(bad_closure_index, -1); |
| 3792 | 3792 |
| 3793 // Retrieve closure function via index. | 3793 // Retrieve closure function via index. |
| 3794 Function& func_from_index = Function::Handle(); | 3794 Function& func_from_index = Function::Handle(); |
| 3795 func_from_index ^= iso->ClosureFunctionFromIndex(good_closure_index); | 3795 func_from_index ^= iso->ClosureFunctionFromIndex(good_closure_index); |
| 3796 // Same closure function. | 3796 // Same closure function. |
| 3797 EXPECT_EQ(func_from_index.raw(), function.raw()); | 3797 EXPECT_EQ(func_from_index.raw(), function.raw()); |
| 3798 } | 3798 } |
| 3799 | 3799 |
| 3800 | 3800 |
| 3801 VM_TEST_CASE(FindInvocationDispatcherFunctionIndex) { | 3801 ISOLATE_UNIT_TEST_CASE(FindInvocationDispatcherFunctionIndex) { |
| 3802 const String& class_name = String::Handle(Symbols::New(thread, "MyClass")); | 3802 const String& class_name = String::Handle(Symbols::New(thread, "MyClass")); |
| 3803 const Script& script = Script::Handle(); | 3803 const Script& script = Script::Handle(); |
| 3804 const Class& cls = Class::Handle(CreateDummyClass(class_name, script)); | 3804 const Class& cls = Class::Handle(CreateDummyClass(class_name, script)); |
| 3805 ClassFinalizer::FinalizeTypesInClass(cls); | 3805 ClassFinalizer::FinalizeTypesInClass(cls); |
| 3806 | 3806 |
| 3807 const Array& functions = Array::Handle(Array::New(1)); | 3807 const Array& functions = Array::Handle(Array::New(1)); |
| 3808 Function& parent = Function::Handle(); | 3808 Function& parent = Function::Handle(); |
| 3809 const String& parent_name = String::Handle(Symbols::New(thread, "foo_papa")); | 3809 const String& parent_name = String::Handle(Symbols::New(thread, "foo_papa")); |
| 3810 parent = | 3810 parent = |
| 3811 Function::New(parent_name, RawFunction::kRegularFunction, false, false, | 3811 Function::New(parent_name, RawFunction::kRegularFunction, false, false, |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4044 const Function& func_b = Function::Handle(GetFunction(class_a, "b")); | 4044 const Function& func_b = Function::Handle(GetFunction(class_a, "b")); |
| 4045 EXPECT(func_b.CanBeInlined()); | 4045 EXPECT(func_b.CanBeInlined()); |
| 4046 | 4046 |
| 4047 // After setting a breakpoint in a function A.b, it is no longer inlineable. | 4047 // After setting a breakpoint in a function A.b, it is no longer inlineable. |
| 4048 result = Dart_SetBreakpoint(NewString(TestCase::url()), kBreakpointLine); | 4048 result = Dart_SetBreakpoint(NewString(TestCase::url()), kBreakpointLine); |
| 4049 EXPECT_VALID(result); | 4049 EXPECT_VALID(result); |
| 4050 EXPECT(!func_b.CanBeInlined()); | 4050 EXPECT(!func_b.CanBeInlined()); |
| 4051 } | 4051 } |
| 4052 | 4052 |
| 4053 | 4053 |
| 4054 VM_TEST_CASE(SpecialClassesHaveEmptyArrays) { | 4054 ISOLATE_UNIT_TEST_CASE(SpecialClassesHaveEmptyArrays) { |
| 4055 ObjectStore* object_store = Isolate::Current()->object_store(); | 4055 ObjectStore* object_store = Isolate::Current()->object_store(); |
| 4056 Class& cls = Class::Handle(); | 4056 Class& cls = Class::Handle(); |
| 4057 Object& array = Object::Handle(); | 4057 Object& array = Object::Handle(); |
| 4058 | 4058 |
| 4059 cls = object_store->null_class(); | 4059 cls = object_store->null_class(); |
| 4060 array = cls.fields(); | 4060 array = cls.fields(); |
| 4061 EXPECT(!array.IsNull()); | 4061 EXPECT(!array.IsNull()); |
| 4062 EXPECT(array.IsArray()); | 4062 EXPECT(array.IsArray()); |
| 4063 array = cls.functions(); | 4063 array = cls.functions(); |
| 4064 EXPECT(!array.IsNull()); | 4064 EXPECT(!array.IsNull()); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4100 return; | 4100 return; |
| 4101 } | 4101 } |
| 4102 objects_->Add(&handle); | 4102 objects_->Add(&handle); |
| 4103 } | 4103 } |
| 4104 | 4104 |
| 4105 private: | 4105 private: |
| 4106 GrowableArray<Object*>* objects_; | 4106 GrowableArray<Object*>* objects_; |
| 4107 }; | 4107 }; |
| 4108 | 4108 |
| 4109 | 4109 |
| 4110 VM_TEST_CASE(PrintJSON) { | 4110 ISOLATE_UNIT_TEST_CASE(PrintJSON) { |
| 4111 Heap* heap = Isolate::Current()->heap(); | 4111 Heap* heap = Isolate::Current()->heap(); |
| 4112 heap->CollectAllGarbage(); | 4112 heap->CollectAllGarbage(); |
| 4113 GrowableArray<Object*> objects; | 4113 GrowableArray<Object*> objects; |
| 4114 ObjectAccumulator acc(&objects); | 4114 ObjectAccumulator acc(&objects); |
| 4115 heap->IterateObjects(&acc); | 4115 heap->IterateObjects(&acc); |
| 4116 for (intptr_t i = 0; i < objects.length(); ++i) { | 4116 for (intptr_t i = 0; i < objects.length(); ++i) { |
| 4117 JSONStream js; | 4117 JSONStream js; |
| 4118 objects[i]->PrintJSON(&js, false); | 4118 objects[i]->PrintJSON(&js, false); |
| 4119 EXPECT_SUBSTRING("\"type\":", js.ToCString()); | 4119 EXPECT_SUBSTRING("\"type\":", js.ToCString()); |
| 4120 } | 4120 } |
| 4121 } | 4121 } |
| 4122 | 4122 |
| 4123 | 4123 |
| 4124 VM_TEST_CASE(PrintJSONPrimitives) { | 4124 ISOLATE_UNIT_TEST_CASE(PrintJSONPrimitives) { |
| 4125 char buffer[1024]; | 4125 char buffer[1024]; |
| 4126 Isolate* isolate = Isolate::Current(); | 4126 Isolate* isolate = Isolate::Current(); |
| 4127 | 4127 |
| 4128 // Class reference | 4128 // Class reference |
| 4129 { | 4129 { |
| 4130 JSONStream js; | 4130 JSONStream js; |
| 4131 Class& cls = Class::Handle(isolate->object_store()->bool_class()); | 4131 Class& cls = Class::Handle(isolate->object_store()->bool_class()); |
| 4132 cls.PrintJSON(&js, true); | 4132 cls.PrintJSON(&js, true); |
| 4133 ElideJSONSubstring("classes", js.ToCString(), buffer); | 4133 ElideJSONSubstring("classes", js.ToCString(), buffer); |
| 4134 EXPECT_STREQ( | 4134 EXPECT_STREQ( |
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4584 pieces.Add(*data[i]); | 4584 pieces.Add(*data[i]); |
| 4585 array.SetAt(i, *data[i]); | 4585 array.SetAt(i, *data[i]); |
| 4586 } | 4586 } |
| 4587 const String& res1 = | 4587 const String& res1 = |
| 4588 String::Handle(zone, Symbols::FromConcatAll(thread, pieces)); | 4588 String::Handle(zone, Symbols::FromConcatAll(thread, pieces)); |
| 4589 const String& res2 = String::Handle(zone, String::ConcatAll(array)); | 4589 const String& res2 = String::Handle(zone, String::ConcatAll(array)); |
| 4590 EXPECT(res1.Equals(res2)); | 4590 EXPECT(res1.Equals(res2)); |
| 4591 } | 4591 } |
| 4592 | 4592 |
| 4593 | 4593 |
| 4594 VM_TEST_CASE(Symbols_FromConcatAll) { | 4594 ISOLATE_UNIT_TEST_CASE(Symbols_FromConcatAll) { |
| 4595 { | 4595 { |
| 4596 const String* data[3] = {&Symbols::FallThroughError(), &Symbols::Dot(), | 4596 const String* data[3] = {&Symbols::FallThroughError(), &Symbols::Dot(), |
| 4597 &Symbols::isPaused()}; | 4597 &Symbols::isPaused()}; |
| 4598 CheckConcatAll(data, 3); | 4598 CheckConcatAll(data, 3); |
| 4599 } | 4599 } |
| 4600 | 4600 |
| 4601 { | 4601 { |
| 4602 const intptr_t kWideCharsLen = 7; | 4602 const intptr_t kWideCharsLen = 7; |
| 4603 uint16_t wide_chars[kWideCharsLen] = {'H', 'e', 'l', 'l', 'o', 256, '!'}; | 4603 uint16_t wide_chars[kWideCharsLen] = {'H', 'e', 'l', 'l', 'o', 256, '!'}; |
| 4604 const String& two_str = | 4604 const String& two_str = |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4654 } | 4654 } |
| 4655 } | 4655 } |
| 4656 | 4656 |
| 4657 | 4657 |
| 4658 struct TestResult { | 4658 struct TestResult { |
| 4659 const char* in; | 4659 const char* in; |
| 4660 const char* out; | 4660 const char* out; |
| 4661 }; | 4661 }; |
| 4662 | 4662 |
| 4663 | 4663 |
| 4664 VM_TEST_CASE(String_ScrubName) { | 4664 ISOLATE_UNIT_TEST_CASE(String_ScrubName) { |
| 4665 TestResult tests[] = { | 4665 TestResult tests[] = { |
| 4666 {"(dynamic, dynamic) => void", "(dynamic, dynamic) => void"}, | 4666 {"(dynamic, dynamic) => void", "(dynamic, dynamic) => void"}, |
| 4667 {"_List@915557746", "_List"}, | 4667 {"_List@915557746", "_List"}, |
| 4668 {"_HashMap@600006304<K, V>(dynamic) => V", | 4668 {"_HashMap@600006304<K, V>(dynamic) => V", |
| 4669 "_HashMap<K, V>(dynamic) => V"}, | 4669 "_HashMap<K, V>(dynamic) => V"}, |
| 4670 {"set:foo", "foo="}, | 4670 {"set:foo", "foo="}, |
| 4671 {"get:foo", "foo"}, | 4671 {"get:foo", "foo"}, |
| 4672 {"_ReceivePortImpl@709387912", "_ReceivePortImpl"}, | 4672 {"_ReceivePortImpl@709387912", "_ReceivePortImpl"}, |
| 4673 {"_ReceivePortImpl@709387912._internal@709387912", | 4673 {"_ReceivePortImpl@709387912._internal@709387912", |
| 4674 "_ReceivePortImpl._internal"}, | 4674 "_ReceivePortImpl._internal"}, |
| 4675 {"_C@6328321&_E@6328321&_F@6328321", "_C&_E&_F"}, | 4675 {"_C@6328321&_E@6328321&_F@6328321", "_C&_E&_F"}, |
| 4676 {"List.", "List"}, | 4676 {"List.", "List"}, |
| 4677 {"get:foo@6328321", "foo"}, | 4677 {"get:foo@6328321", "foo"}, |
| 4678 {"_MyClass@6328321.", "_MyClass"}, | 4678 {"_MyClass@6328321.", "_MyClass"}, |
| 4679 {"_MyClass@6328321.named", "_MyClass.named"}, | 4679 {"_MyClass@6328321.named", "_MyClass.named"}, |
| 4680 }; | 4680 }; |
| 4681 String& test = String::Handle(); | 4681 String& test = String::Handle(); |
| 4682 String& result = String::Handle(); | 4682 String& result = String::Handle(); |
| 4683 for (size_t i = 0; i < ARRAY_SIZE(tests); i++) { | 4683 for (size_t i = 0; i < ARRAY_SIZE(tests); i++) { |
| 4684 test = String::New(tests[i].in); | 4684 test = String::New(tests[i].in); |
| 4685 result = String::ScrubName(test); | 4685 result = String::ScrubName(test); |
| 4686 EXPECT_STREQ(tests[i].out, result.ToCString()); | 4686 EXPECT_STREQ(tests[i].out, result.ToCString()); |
| 4687 } | 4687 } |
| 4688 } | 4688 } |
| 4689 | 4689 |
| 4690 | 4690 |
| 4691 VM_TEST_CASE(String_EqualsUTF32) { | 4691 ISOLATE_UNIT_TEST_CASE(String_EqualsUTF32) { |
| 4692 // Regression test for Issue 27433. Checks that comparisons between Strings | 4692 // Regression test for Issue 27433. Checks that comparisons between Strings |
| 4693 // and utf32 arrays happens after conversion to utf16 instead of utf32, as | 4693 // and utf32 arrays happens after conversion to utf16 instead of utf32, as |
| 4694 // required for proper canonicalization of string literals with a lossy | 4694 // required for proper canonicalization of string literals with a lossy |
| 4695 // utf32->utf16 conversion. | 4695 // utf32->utf16 conversion. |
| 4696 int32_t char_codes[] = {0, 0x0a, 0x0d, 0x7f, 0xff, | 4696 int32_t char_codes[] = {0, 0x0a, 0x0d, 0x7f, 0xff, |
| 4697 0xffff, 0xd800, 0xdc00, 0xdbff, 0xdfff}; | 4697 0xffff, 0xd800, 0xdc00, 0xdbff, 0xdfff}; |
| 4698 | 4698 |
| 4699 const String& str = | 4699 const String& str = |
| 4700 String::Handle(String::FromUTF32(char_codes, ARRAY_SIZE(char_codes))); | 4700 String::Handle(String::FromUTF32(char_codes, ARRAY_SIZE(char_codes))); |
| 4701 EXPECT(str.Equals(char_codes, ARRAY_SIZE(char_codes))); | 4701 EXPECT(str.Equals(char_codes, ARRAY_SIZE(char_codes))); |
| 4702 } | 4702 } |
| 4703 | 4703 |
| 4704 } // namespace dart | 4704 } // namespace dart |
| OLD | NEW |