| 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 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 static RawClass* CreateDummyClass(const String& class_name, | 29 static RawClass* CreateDummyClass(const String& class_name, |
| 30 const Script& script) { | 30 const Script& script) { |
| 31 const Class& cls = Class::Handle( | 31 const Class& cls = Class::Handle( |
| 32 Class::New(class_name, script, Scanner::kNoSourcePos)); | 32 Class::New(class_name, script, Scanner::kNoSourcePos)); |
| 33 cls.set_is_synthesized_class(); // Dummy class for testing. | 33 cls.set_is_synthesized_class(); // Dummy class for testing. |
| 34 return cls.raw(); | 34 return cls.raw(); |
| 35 } | 35 } |
| 36 | 36 |
| 37 | 37 |
| 38 TEST_CASE(Class) { | 38 VM_TEST_CASE(Class) { |
| 39 // Allocate the class first. | 39 // Allocate the class first. |
| 40 const String& class_name = String::Handle(Symbols::New("MyClass")); | 40 const String& class_name = String::Handle(Symbols::New("MyClass")); |
| 41 const Script& script = Script::Handle(); | 41 const Script& script = Script::Handle(); |
| 42 const Class& cls = Class::Handle(CreateDummyClass(class_name, script)); | 42 const Class& cls = Class::Handle(CreateDummyClass(class_name, script)); |
| 43 | 43 |
| 44 // Class has no fields and no functions yet. | 44 // Class has no fields and no functions yet. |
| 45 EXPECT_EQ(Array::Handle(cls.fields()).Length(), 0); | 45 EXPECT_EQ(Array::Handle(cls.fields()).Length(), 0); |
| 46 EXPECT_EQ(Array::Handle(cls.functions()).Length(), 0); | 46 EXPECT_EQ(Array::Handle(cls.functions()).Length(), 0); |
| 47 | 47 |
| 48 // Setup the interfaces in the class. | 48 // Setup the interfaces in the class. |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 EXPECT(!function.HasOptionalParameters()); | 136 EXPECT(!function.HasOptionalParameters()); |
| 137 | 137 |
| 138 function_name = String::New("bar"); | 138 function_name = String::New("bar"); |
| 139 function = cls.LookupDynamicFunction(function_name); | 139 function = cls.LookupDynamicFunction(function_name); |
| 140 EXPECT(!function.IsNull()); | 140 EXPECT(!function.IsNull()); |
| 141 EXPECT_EQ(kNumFixedParameters, function.num_fixed_parameters()); | 141 EXPECT_EQ(kNumFixedParameters, function.num_fixed_parameters()); |
| 142 EXPECT_EQ(kNumOptionalParameters, function.NumOptionalParameters()); | 142 EXPECT_EQ(kNumOptionalParameters, function.NumOptionalParameters()); |
| 143 } | 143 } |
| 144 | 144 |
| 145 | 145 |
| 146 TEST_CASE(TypeArguments) { | 146 VM_TEST_CASE(TypeArguments) { |
| 147 const Type& type1 = Type::Handle(Type::Double()); | 147 const Type& type1 = Type::Handle(Type::Double()); |
| 148 const Type& type2 = Type::Handle(Type::StringType()); | 148 const Type& type2 = Type::Handle(Type::StringType()); |
| 149 const TypeArguments& type_arguments1 = TypeArguments::Handle( | 149 const TypeArguments& type_arguments1 = TypeArguments::Handle( |
| 150 TypeArguments::New(2)); | 150 TypeArguments::New(2)); |
| 151 type_arguments1.SetTypeAt(0, type1); | 151 type_arguments1.SetTypeAt(0, type1); |
| 152 type_arguments1.SetTypeAt(1, type2); | 152 type_arguments1.SetTypeAt(1, type2); |
| 153 const TypeArguments& type_arguments2 = TypeArguments::Handle( | 153 const TypeArguments& type_arguments2 = TypeArguments::Handle( |
| 154 TypeArguments::New(2)); | 154 TypeArguments::New(2)); |
| 155 type_arguments2.SetTypeAt(0, type1); | 155 type_arguments2.SetTypeAt(0, type1); |
| 156 type_arguments2.SetTypeAt(1, type2); | 156 type_arguments2.SetTypeAt(1, type2); |
| 157 EXPECT_NE(type_arguments1.raw(), type_arguments2.raw()); | 157 EXPECT_NE(type_arguments1.raw(), type_arguments2.raw()); |
| 158 OS::Print("1: %s\n", type_arguments1.ToCString()); | 158 OS::Print("1: %s\n", type_arguments1.ToCString()); |
| 159 OS::Print("2: %s\n", type_arguments2.ToCString()); | 159 OS::Print("2: %s\n", type_arguments2.ToCString()); |
| 160 EXPECT(type_arguments1.Equals(type_arguments2)); | 160 EXPECT(type_arguments1.Equals(type_arguments2)); |
| 161 TypeArguments& type_arguments3 = TypeArguments::Handle(); | 161 TypeArguments& type_arguments3 = TypeArguments::Handle(); |
| 162 type_arguments1.Canonicalize(); | 162 type_arguments1.Canonicalize(); |
| 163 type_arguments3 ^= type_arguments2.Canonicalize(); | 163 type_arguments3 ^= type_arguments2.Canonicalize(); |
| 164 EXPECT_EQ(type_arguments1.raw(), type_arguments3.raw()); | 164 EXPECT_EQ(type_arguments1.raw(), type_arguments3.raw()); |
| 165 } | 165 } |
| 166 | 166 |
| 167 | 167 |
| 168 TEST_CASE(TokenStream) { | 168 VM_TEST_CASE(TokenStream) { |
| 169 String& source = String::Handle(String::New("= ( 9 , .")); | 169 String& source = String::Handle(String::New("= ( 9 , .")); |
| 170 String& private_key = String::Handle(String::New("")); | 170 String& private_key = String::Handle(String::New("")); |
| 171 Scanner scanner(source, private_key); | 171 Scanner scanner(source, private_key); |
| 172 const Scanner::GrowableTokenStream& ts = scanner.GetStream(); | 172 const Scanner::GrowableTokenStream& ts = scanner.GetStream(); |
| 173 EXPECT_EQ(6, ts.length()); | 173 EXPECT_EQ(6, ts.length()); |
| 174 EXPECT_EQ(Token::kLPAREN, ts[1].kind); | 174 EXPECT_EQ(Token::kLPAREN, ts[1].kind); |
| 175 const TokenStream& token_stream = TokenStream::Handle( | 175 const TokenStream& token_stream = TokenStream::Handle( |
| 176 TokenStream::New(ts, private_key, false)); | 176 TokenStream::New(ts, private_key, false)); |
| 177 TokenStream::Iterator iterator(token_stream, 0); | 177 TokenStream::Iterator iterator(token_stream, 0); |
| 178 // EXPECT_EQ(6, token_stream.Length()); | 178 // EXPECT_EQ(6, token_stream.Length()); |
| 179 iterator.Advance(); // Advance to '(' token. | 179 iterator.Advance(); // Advance to '(' token. |
| 180 EXPECT_EQ(Token::kLPAREN, iterator.CurrentTokenKind()); | 180 EXPECT_EQ(Token::kLPAREN, iterator.CurrentTokenKind()); |
| 181 iterator.Advance(); | 181 iterator.Advance(); |
| 182 iterator.Advance(); | 182 iterator.Advance(); |
| 183 iterator.Advance(); // Advance to '.' token. | 183 iterator.Advance(); // Advance to '.' token. |
| 184 EXPECT_EQ(Token::kPERIOD, iterator.CurrentTokenKind()); | 184 EXPECT_EQ(Token::kPERIOD, iterator.CurrentTokenKind()); |
| 185 iterator.Advance(); // Advance to end of stream. | 185 iterator.Advance(); // Advance to end of stream. |
| 186 EXPECT_EQ(Token::kEOS, iterator.CurrentTokenKind()); | 186 EXPECT_EQ(Token::kEOS, iterator.CurrentTokenKind()); |
| 187 } | 187 } |
| 188 | 188 |
| 189 | 189 |
| 190 TEST_CASE(GenerateExactSource) { | 190 VM_TEST_CASE(GenerateExactSource) { |
| 191 // Verify the exact formatting of generated sources. | 191 // Verify the exact formatting of generated sources. |
| 192 const char* kScriptChars = | 192 const char* kScriptChars = |
| 193 "\n" | 193 "\n" |
| 194 "class A {\n" | 194 "class A {\n" |
| 195 " static bar() { return 42; }\n" | 195 " static bar() { return 42; }\n" |
| 196 " static fly() { return 5; }\n" | 196 " static fly() { return 5; }\n" |
| 197 " void catcher(x) {\n" | 197 " void catcher(x) {\n" |
| 198 " try {\n" | 198 " try {\n" |
| 199 " if (x) {\n" | 199 " if (x) {\n" |
| 200 " fly();\n" | 200 " fly();\n" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 EXPECT(!cls.IsNull()); | 243 EXPECT(!cls.IsNull()); |
| 244 const intptr_t end_token_pos = cls.ComputeEndTokenPos(); | 244 const intptr_t end_token_pos = cls.ComputeEndTokenPos(); |
| 245 const Script& scr = Script::Handle(cls.script()); | 245 const Script& scr = Script::Handle(cls.script()); |
| 246 intptr_t line; | 246 intptr_t line; |
| 247 intptr_t col; | 247 intptr_t col; |
| 248 scr.GetTokenLocation(end_token_pos, &line, &col); | 248 scr.GetTokenLocation(end_token_pos, &line, &col); |
| 249 EXPECT(line == 10 && col == 1); | 249 EXPECT(line == 10 && col == 1); |
| 250 } | 250 } |
| 251 | 251 |
| 252 | 252 |
| 253 TEST_CASE(InstanceClass) { | 253 VM_TEST_CASE(InstanceClass) { |
| 254 // Allocate the class first. | 254 // Allocate the class first. |
| 255 String& class_name = String::Handle(Symbols::New("EmptyClass")); | 255 String& class_name = String::Handle(Symbols::New("EmptyClass")); |
| 256 Script& script = Script::Handle(); | 256 Script& script = Script::Handle(); |
| 257 const Class& empty_class = | 257 const Class& empty_class = |
| 258 Class::Handle(CreateDummyClass(class_name, script)); | 258 Class::Handle(CreateDummyClass(class_name, script)); |
| 259 | 259 |
| 260 // EmptyClass has no fields and no functions. | 260 // EmptyClass has no fields and no functions. |
| 261 EXPECT_EQ(Array::Handle(empty_class.fields()).Length(), 0); | 261 EXPECT_EQ(Array::Handle(empty_class.fields()).Length(), 0); |
| 262 EXPECT_EQ(Array::Handle(empty_class.functions()).Length(), 0); | 262 EXPECT_EQ(Array::Handle(empty_class.functions()).Length(), 0); |
| 263 | 263 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 289 intptr_t header_size = sizeof(RawObject); | 289 intptr_t header_size = sizeof(RawObject); |
| 290 EXPECT_EQ(Utils::RoundUp((header_size + (1 * kWordSize)), kObjectAlignment), | 290 EXPECT_EQ(Utils::RoundUp((header_size + (1 * kWordSize)), kObjectAlignment), |
| 291 one_field_class.instance_size()); | 291 one_field_class.instance_size()); |
| 292 EXPECT_EQ(header_size, field.Offset()); | 292 EXPECT_EQ(header_size, field.Offset()); |
| 293 EXPECT(!one_field_class.is_implemented()); | 293 EXPECT(!one_field_class.is_implemented()); |
| 294 one_field_class.set_is_implemented(); | 294 one_field_class.set_is_implemented(); |
| 295 EXPECT(one_field_class.is_implemented()); | 295 EXPECT(one_field_class.is_implemented()); |
| 296 } | 296 } |
| 297 | 297 |
| 298 | 298 |
| 299 TEST_CASE(Smi) { | 299 VM_TEST_CASE(Smi) { |
| 300 const Smi& smi = Smi::Handle(Smi::New(5)); | 300 const Smi& smi = Smi::Handle(Smi::New(5)); |
| 301 Object& smi_object = Object::Handle(smi.raw()); | 301 Object& smi_object = Object::Handle(smi.raw()); |
| 302 EXPECT(smi.IsSmi()); | 302 EXPECT(smi.IsSmi()); |
| 303 EXPECT(smi_object.IsSmi()); | 303 EXPECT(smi_object.IsSmi()); |
| 304 EXPECT_EQ(5, smi.Value()); | 304 EXPECT_EQ(5, smi.Value()); |
| 305 const Object& object = Object::Handle(); | 305 const Object& object = Object::Handle(); |
| 306 EXPECT(!object.IsSmi()); | 306 EXPECT(!object.IsSmi()); |
| 307 smi_object = Object::null(); | 307 smi_object = Object::null(); |
| 308 EXPECT(!smi_object.IsSmi()); | 308 EXPECT(!smi_object.IsSmi()); |
| 309 | 309 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 "10000000000000000000")); | 351 "10000000000000000000")); |
| 352 Bigint& big2 = Bigint::Handle(Bigint::NewFromCString( | 352 Bigint& big2 = Bigint::Handle(Bigint::NewFromCString( |
| 353 "-10000000000000000000")); | 353 "-10000000000000000000")); |
| 354 EXPECT_EQ(-1, a.CompareWith(big1)); | 354 EXPECT_EQ(-1, a.CompareWith(big1)); |
| 355 EXPECT_EQ(1, a.CompareWith(big2)); | 355 EXPECT_EQ(1, a.CompareWith(big2)); |
| 356 EXPECT_EQ(-1, c.CompareWith(big1)); | 356 EXPECT_EQ(-1, c.CompareWith(big1)); |
| 357 EXPECT_EQ(1, c.CompareWith(big2)); | 357 EXPECT_EQ(1, c.CompareWith(big2)); |
| 358 } | 358 } |
| 359 | 359 |
| 360 | 360 |
| 361 TEST_CASE(StringCompareTo) { | 361 VM_TEST_CASE(StringCompareTo) { |
| 362 const String& abcd = String::Handle(String::New("abcd")); | 362 const String& abcd = String::Handle(String::New("abcd")); |
| 363 const String& abce = String::Handle(String::New("abce")); | 363 const String& abce = String::Handle(String::New("abce")); |
| 364 EXPECT_EQ(0, abcd.CompareTo(abcd)); | 364 EXPECT_EQ(0, abcd.CompareTo(abcd)); |
| 365 EXPECT_EQ(0, abce.CompareTo(abce)); | 365 EXPECT_EQ(0, abce.CompareTo(abce)); |
| 366 EXPECT(abcd.CompareTo(abce) < 0); | 366 EXPECT(abcd.CompareTo(abce) < 0); |
| 367 EXPECT(abce.CompareTo(abcd) > 0); | 367 EXPECT(abce.CompareTo(abcd) > 0); |
| 368 | 368 |
| 369 const int kMonkeyLen = 4; | 369 const int kMonkeyLen = 4; |
| 370 const uint8_t monkey_utf8[kMonkeyLen] = { 0xf0, 0x9f, 0x90, 0xb5 }; | 370 const uint8_t monkey_utf8[kMonkeyLen] = { 0xf0, 0x9f, 0x90, 0xb5 }; |
| 371 const String& monkey_face = | 371 const String& monkey_face = |
| (...skipping 23 matching lines...) Expand all Loading... |
| 395 EXPECT(abce.CompareTo(monkey_face) < 0); | 395 EXPECT(abce.CompareTo(monkey_face) < 0); |
| 396 EXPECT(abcd.CompareTo(domino) < 0); | 396 EXPECT(abcd.CompareTo(domino) < 0); |
| 397 EXPECT(abce.CompareTo(domino) < 0); | 397 EXPECT(abce.CompareTo(domino) < 0); |
| 398 EXPECT(domino.CompareTo(abcd) > 0); | 398 EXPECT(domino.CompareTo(abcd) > 0); |
| 399 EXPECT(domino.CompareTo(abcd) > 0); | 399 EXPECT(domino.CompareTo(abcd) > 0); |
| 400 EXPECT(monkey_face.CompareTo(abce) > 0); | 400 EXPECT(monkey_face.CompareTo(abce) > 0); |
| 401 EXPECT(monkey_face.CompareTo(abce) > 0); | 401 EXPECT(monkey_face.CompareTo(abce) > 0); |
| 402 } | 402 } |
| 403 | 403 |
| 404 | 404 |
| 405 TEST_CASE(StringEncodeIRI) { | 405 VM_TEST_CASE(StringEncodeIRI) { |
| 406 const char* kInput = | 406 const char* kInput = |
| 407 "file:///usr/local/johnmccutchan/workspace/dart-repo/dart/test.dart"; | 407 "file:///usr/local/johnmccutchan/workspace/dart-repo/dart/test.dart"; |
| 408 const char* kOutput = | 408 const char* kOutput = |
| 409 "file%3A%2F%2F%2Fusr%2Flocal%2Fjohnmccutchan%2Fworkspace%2F" | 409 "file%3A%2F%2F%2Fusr%2Flocal%2Fjohnmccutchan%2Fworkspace%2F" |
| 410 "dart-repo%2Fdart%2Ftest.dart"; | 410 "dart-repo%2Fdart%2Ftest.dart"; |
| 411 const String& input = String::Handle(String::New(kInput)); | 411 const String& input = String::Handle(String::New(kInput)); |
| 412 const String& output = String::Handle(String::New(kOutput)); | 412 const String& output = String::Handle(String::New(kOutput)); |
| 413 const String& encoded = String::Handle(String::EncodeIRI(input)); | 413 const String& encoded = String::Handle(String::EncodeIRI(input)); |
| 414 EXPECT(output.Equals(encoded)); | 414 EXPECT(output.Equals(encoded)); |
| 415 } | 415 } |
| 416 | 416 |
| 417 | 417 |
| 418 TEST_CASE(StringDecodeIRI) { | 418 VM_TEST_CASE(StringDecodeIRI) { |
| 419 const char* kOutput = | 419 const char* kOutput = |
| 420 "file:///usr/local/johnmccutchan/workspace/dart-repo/dart/test.dart"; | 420 "file:///usr/local/johnmccutchan/workspace/dart-repo/dart/test.dart"; |
| 421 const char* kInput = | 421 const char* kInput = |
| 422 "file%3A%2F%2F%2Fusr%2Flocal%2Fjohnmccutchan%2Fworkspace%2F" | 422 "file%3A%2F%2F%2Fusr%2Flocal%2Fjohnmccutchan%2Fworkspace%2F" |
| 423 "dart-repo%2Fdart%2Ftest.dart"; | 423 "dart-repo%2Fdart%2Ftest.dart"; |
| 424 const String& input = String::Handle(String::New(kInput)); | 424 const String& input = String::Handle(String::New(kInput)); |
| 425 const String& output = String::Handle(String::New(kOutput)); | 425 const String& output = String::Handle(String::New(kOutput)); |
| 426 const String& decoded = String::Handle(String::DecodeIRI(input)); | 426 const String& decoded = String::Handle(String::DecodeIRI(input)); |
| 427 EXPECT(output.Equals(decoded)); | 427 EXPECT(output.Equals(decoded)); |
| 428 } | 428 } |
| 429 | 429 |
| 430 | 430 |
| 431 TEST_CASE(StringDecodeIRIInvalid) { | 431 VM_TEST_CASE(StringDecodeIRIInvalid) { |
| 432 String& input = String::Handle(); | 432 String& input = String::Handle(); |
| 433 input = String::New("file%"); | 433 input = String::New("file%"); |
| 434 String& decoded = String::Handle(); | 434 String& decoded = String::Handle(); |
| 435 decoded = String::DecodeIRI(input); | 435 decoded = String::DecodeIRI(input); |
| 436 EXPECT(decoded.IsNull()); | 436 EXPECT(decoded.IsNull()); |
| 437 input = String::New("file%3"); | 437 input = String::New("file%3"); |
| 438 decoded = String::DecodeIRI(input); | 438 decoded = String::DecodeIRI(input); |
| 439 EXPECT(decoded.IsNull()); | 439 EXPECT(decoded.IsNull()); |
| 440 input = String::New("file%3g"); | 440 input = String::New("file%3g"); |
| 441 decoded = String::DecodeIRI(input); | 441 decoded = String::DecodeIRI(input); |
| 442 EXPECT(decoded.IsNull()); | 442 EXPECT(decoded.IsNull()); |
| 443 } | 443 } |
| 444 | 444 |
| 445 | 445 |
| 446 TEST_CASE(StringIRITwoByte) { | 446 VM_TEST_CASE(StringIRITwoByte) { |
| 447 const intptr_t kInputLen = 3; | 447 const intptr_t kInputLen = 3; |
| 448 const uint16_t kInput[kInputLen] = { 'x', '/', 256 }; | 448 const uint16_t kInput[kInputLen] = { 'x', '/', 256 }; |
| 449 const String& input = String::Handle(String::FromUTF16(kInput, kInputLen)); | 449 const String& input = String::Handle(String::FromUTF16(kInput, kInputLen)); |
| 450 const intptr_t kOutputLen = 10; | 450 const intptr_t kOutputLen = 10; |
| 451 const uint16_t kOutput[kOutputLen] = | 451 const uint16_t kOutput[kOutputLen] = |
| 452 { 'x', '%', '2', 'F', '%', 'C', '4', '%', '8', '0' }; | 452 { 'x', '%', '2', 'F', '%', 'C', '4', '%', '8', '0' }; |
| 453 const String& output = String::Handle(String::FromUTF16(kOutput, kOutputLen)); | 453 const String& output = String::Handle(String::FromUTF16(kOutput, kOutputLen)); |
| 454 const String& encoded = String::Handle(String::EncodeIRI(input)); | 454 const String& encoded = String::Handle(String::EncodeIRI(input)); |
| 455 EXPECT(output.Equals(encoded)); | 455 EXPECT(output.Equals(encoded)); |
| 456 const String& decoded = String::Handle(String::DecodeIRI(output)); | 456 const String& decoded = String::Handle(String::DecodeIRI(output)); |
| 457 EXPECT(input.Equals(decoded)); | 457 EXPECT(input.Equals(decoded)); |
| 458 } | 458 } |
| 459 | 459 |
| 460 | 460 |
| 461 TEST_CASE(Mint) { | 461 VM_TEST_CASE(Mint) { |
| 462 // On 64-bit architectures a Smi is stored in a 64 bit word. A Midint cannot | 462 // On 64-bit architectures a Smi is stored in a 64 bit word. A Midint cannot |
| 463 // be allocated if it does fit into a Smi. | 463 // be allocated if it does fit into a Smi. |
| 464 #if !defined(ARCH_IS_64_BIT) | 464 #if !defined(ARCH_IS_64_BIT) |
| 465 { Mint& med = Mint::Handle(); | 465 { Mint& med = Mint::Handle(); |
| 466 EXPECT(med.IsNull()); | 466 EXPECT(med.IsNull()); |
| 467 int64_t v = DART_2PART_UINT64_C(1, 0); | 467 int64_t v = DART_2PART_UINT64_C(1, 0); |
| 468 med ^= Integer::New(v); | 468 med ^= Integer::New(v); |
| 469 EXPECT_EQ(v, med.value()); | 469 EXPECT_EQ(v, med.value()); |
| 470 const String& smi_str = String::Handle(String::New("1")); | 470 const String& smi_str = String::Handle(String::New("1")); |
| 471 const String& mint1_str = String::Handle(String::New("2147419168")); | 471 const String& mint1_str = String::Handle(String::New("2147419168")); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 mint1 ^= Integer::NewCanonical(mint_string); | 525 mint1 ^= Integer::NewCanonical(mint_string); |
| 526 Mint& mint2 = Mint::Handle(); | 526 Mint& mint2 = Mint::Handle(); |
| 527 mint2 ^= Integer::NewCanonical(mint_string); | 527 mint2 ^= Integer::NewCanonical(mint_string); |
| 528 EXPECT_EQ(mint1.value(), mint_value); | 528 EXPECT_EQ(mint1.value(), mint_value); |
| 529 EXPECT_EQ(mint2.value(), mint_value); | 529 EXPECT_EQ(mint2.value(), mint_value); |
| 530 EXPECT_EQ(mint1.raw(), mint2.raw()); | 530 EXPECT_EQ(mint1.raw(), mint2.raw()); |
| 531 #endif | 531 #endif |
| 532 } | 532 } |
| 533 | 533 |
| 534 | 534 |
| 535 TEST_CASE(Double) { | 535 VM_TEST_CASE(Double) { |
| 536 { | 536 { |
| 537 const double dbl_const = 5.0; | 537 const double dbl_const = 5.0; |
| 538 const Double& dbl = Double::Handle(Double::New(dbl_const)); | 538 const Double& dbl = Double::Handle(Double::New(dbl_const)); |
| 539 Object& dbl_object = Object::Handle(dbl.raw()); | 539 Object& dbl_object = Object::Handle(dbl.raw()); |
| 540 EXPECT(dbl.IsDouble()); | 540 EXPECT(dbl.IsDouble()); |
| 541 EXPECT(dbl_object.IsDouble()); | 541 EXPECT(dbl_object.IsDouble()); |
| 542 EXPECT_EQ(dbl_const, dbl.value()); | 542 EXPECT_EQ(dbl_const, dbl.value()); |
| 543 } | 543 } |
| 544 | 544 |
| 545 { | 545 { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 609 EXPECT_EQ(2.0, dbl1.value()); | 609 EXPECT_EQ(2.0, dbl1.value()); |
| 610 | 610 |
| 611 // Disallow legacy form. | 611 // Disallow legacy form. |
| 612 const String& dbl_str2 = String::Handle(String::New("2.0d")); | 612 const String& dbl_str2 = String::Handle(String::New("2.0d")); |
| 613 const Double& dbl2 = Double::Handle(Double::New(dbl_str2)); | 613 const Double& dbl2 = Double::Handle(Double::New(dbl_str2)); |
| 614 EXPECT(dbl2.IsNull()); | 614 EXPECT(dbl2.IsNull()); |
| 615 } | 615 } |
| 616 } | 616 } |
| 617 | 617 |
| 618 | 618 |
| 619 TEST_CASE(Bigint) { | 619 VM_TEST_CASE(Bigint) { |
| 620 Bigint& b = Bigint::Handle(); | 620 Bigint& b = Bigint::Handle(); |
| 621 EXPECT(b.IsNull()); | 621 EXPECT(b.IsNull()); |
| 622 const char* cstr = "18446744073709551615000"; | 622 const char* cstr = "18446744073709551615000"; |
| 623 const String& test = String::Handle(String::New(cstr)); | 623 const String& test = String::Handle(String::New(cstr)); |
| 624 b ^= Integer::NewCanonical(test); | 624 b ^= Integer::NewCanonical(test); |
| 625 const char* str = b.ToCString(); | 625 const char* str = b.ToCString(); |
| 626 EXPECT_STREQ(cstr, str); | 626 EXPECT_STREQ(cstr, str); |
| 627 | 627 |
| 628 int64_t t64 = DART_2PART_UINT64_C(1, 0); | 628 int64_t t64 = DART_2PART_UINT64_C(1, 0); |
| 629 Bigint& big = Bigint::Handle(Bigint::NewFromInt64(t64)); | 629 Bigint& big = Bigint::Handle(Bigint::NewFromInt64(t64)); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 648 Smi& smi2 = Smi::Handle(Smi::New(-2)); | 648 Smi& smi2 = Smi::Handle(Smi::New(-2)); |
| 649 | 649 |
| 650 EXPECT_EQ(-1, smi1.CompareWith(big1)); | 650 EXPECT_EQ(-1, smi1.CompareWith(big1)); |
| 651 EXPECT_EQ(-1, smi2.CompareWith(big1)); | 651 EXPECT_EQ(-1, smi2.CompareWith(big1)); |
| 652 | 652 |
| 653 EXPECT_EQ(1, smi1.CompareWith(big3)); | 653 EXPECT_EQ(1, smi1.CompareWith(big3)); |
| 654 EXPECT_EQ(1, smi2.CompareWith(big3)); | 654 EXPECT_EQ(1, smi2.CompareWith(big3)); |
| 655 } | 655 } |
| 656 | 656 |
| 657 | 657 |
| 658 TEST_CASE(Integer) { | 658 VM_TEST_CASE(Integer) { |
| 659 Integer& i = Integer::Handle(); | 659 Integer& i = Integer::Handle(); |
| 660 i = Integer::NewCanonical(String::Handle(String::New("12"))); | 660 i = Integer::NewCanonical(String::Handle(String::New("12"))); |
| 661 EXPECT(i.IsSmi()); | 661 EXPECT(i.IsSmi()); |
| 662 i = Integer::NewCanonical(String::Handle(String::New("-120"))); | 662 i = Integer::NewCanonical(String::Handle(String::New("-120"))); |
| 663 EXPECT(i.IsSmi()); | 663 EXPECT(i.IsSmi()); |
| 664 i = Integer::NewCanonical(String::Handle(String::New("0"))); | 664 i = Integer::NewCanonical(String::Handle(String::New("0"))); |
| 665 EXPECT(i.IsSmi()); | 665 EXPECT(i.IsSmi()); |
| 666 i = Integer::NewCanonical( | 666 i = Integer::NewCanonical( |
| 667 String::Handle(String::New("12345678901234567890"))); | 667 String::Handle(String::New("12345678901234567890"))); |
| 668 EXPECT(i.IsBigint()); | 668 EXPECT(i.IsBigint()); |
| 669 i = Integer::NewCanonical( | 669 i = Integer::NewCanonical( |
| 670 String::Handle(String::New("-12345678901234567890111222"))); | 670 String::Handle(String::New("-12345678901234567890111222"))); |
| 671 EXPECT(i.IsBigint()); | 671 EXPECT(i.IsBigint()); |
| 672 } | 672 } |
| 673 | 673 |
| 674 | 674 |
| 675 TEST_CASE(String) { | 675 VM_TEST_CASE(String) { |
| 676 const char* kHello = "Hello World!"; | 676 const char* kHello = "Hello World!"; |
| 677 int32_t hello_len = strlen(kHello); | 677 int32_t hello_len = strlen(kHello); |
| 678 const String& str = String::Handle(String::New(kHello)); | 678 const String& str = String::Handle(String::New(kHello)); |
| 679 EXPECT(str.IsInstance()); | 679 EXPECT(str.IsInstance()); |
| 680 EXPECT(str.IsString()); | 680 EXPECT(str.IsString()); |
| 681 EXPECT(str.IsOneByteString()); | 681 EXPECT(str.IsOneByteString()); |
| 682 EXPECT(!str.IsTwoByteString()); | 682 EXPECT(!str.IsTwoByteString()); |
| 683 EXPECT(!str.IsNumber()); | 683 EXPECT(!str.IsNumber()); |
| 684 EXPECT_EQ(hello_len, str.Length()); | 684 EXPECT_EQ(hello_len, str.Length()); |
| 685 EXPECT_EQ('H', str.CharAt(0)); | 685 EXPECT_EQ('H', str.CharAt(0)); |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 812 const String& str16 = String::Handle(String::FromUTF32(char32, 3)); | 812 const String& str16 = String::Handle(String::FromUTF32(char32, 3)); |
| 813 EXPECT(!str16.IsOneByteString()); | 813 EXPECT(!str16.IsOneByteString()); |
| 814 EXPECT(str16.IsTwoByteString()); | 814 EXPECT(str16.IsTwoByteString()); |
| 815 EXPECT_EQ(0x0000, str16.CharAt(0)); | 815 EXPECT_EQ(0x0000, str16.CharAt(0)); |
| 816 EXPECT_EQ(0x7FFF, str16.CharAt(1)); | 816 EXPECT_EQ(0x7FFF, str16.CharAt(1)); |
| 817 EXPECT_EQ(0xFFFF, str16.CharAt(2)); | 817 EXPECT_EQ(0xFFFF, str16.CharAt(2)); |
| 818 } | 818 } |
| 819 } | 819 } |
| 820 | 820 |
| 821 | 821 |
| 822 TEST_CASE(StringFormat) { | 822 VM_TEST_CASE(StringFormat) { |
| 823 const char* hello_str = "Hello World!"; | 823 const char* hello_str = "Hello World!"; |
| 824 const String& str = | 824 const String& str = |
| 825 String::Handle(String::NewFormatted("Hello %s!", "World")); | 825 String::Handle(String::NewFormatted("Hello %s!", "World")); |
| 826 EXPECT(str.IsInstance()); | 826 EXPECT(str.IsInstance()); |
| 827 EXPECT(str.IsString()); | 827 EXPECT(str.IsString()); |
| 828 EXPECT(str.IsOneByteString()); | 828 EXPECT(str.IsOneByteString()); |
| 829 EXPECT(!str.IsTwoByteString()); | 829 EXPECT(!str.IsTwoByteString()); |
| 830 EXPECT(!str.IsNumber()); | 830 EXPECT(!str.IsNumber()); |
| 831 EXPECT(str.Equals(hello_str)); | 831 EXPECT(str.Equals(hello_str)); |
| 832 } | 832 } |
| 833 | 833 |
| 834 | 834 |
| 835 TEST_CASE(StringConcat) { | 835 VM_TEST_CASE(StringConcat) { |
| 836 // Create strings from concatenated 1-byte empty strings. | 836 // Create strings from concatenated 1-byte empty strings. |
| 837 { | 837 { |
| 838 const String& empty1 = String::Handle(String::New("")); | 838 const String& empty1 = String::Handle(String::New("")); |
| 839 EXPECT(empty1.IsOneByteString()); | 839 EXPECT(empty1.IsOneByteString()); |
| 840 EXPECT_EQ(0, empty1.Length()); | 840 EXPECT_EQ(0, empty1.Length()); |
| 841 | 841 |
| 842 const String& empty2 = String::Handle(String::New("")); | 842 const String& empty2 = String::Handle(String::New("")); |
| 843 EXPECT(empty2.IsOneByteString()); | 843 EXPECT(empty2.IsOneByteString()); |
| 844 EXPECT_EQ(0, empty2.Length()); | 844 EXPECT_EQ(0, empty2.Length()); |
| 845 | 845 |
| (...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1359 EXPECT_EQ(twostr.Length()*2 + onestr.Length(), two_one_two_str.Length()); | 1359 EXPECT_EQ(twostr.Length()*2 + onestr.Length(), two_one_two_str.Length()); |
| 1360 uint16_t two_one_two[] = { 0x05E6, 0x05D5, 0x05D5, 0x05D9, 0x05D9, | 1360 uint16_t two_one_two[] = { 0x05E6, 0x05D5, 0x05D5, 0x05D9, 0x05D9, |
| 1361 'o', 'n', 'e', ' ', 'b', 'y', 't', 'e', | 1361 'o', 'n', 'e', ' ', 'b', 'y', 't', 'e', |
| 1362 0x05E6, 0x05D5, 0x05D5, 0x05D9, 0x05D9 }; | 1362 0x05E6, 0x05D5, 0x05D5, 0x05D9, 0x05D9 }; |
| 1363 intptr_t two_one_two_len = sizeof(two_one_two) / sizeof(two_one_two[0]); | 1363 intptr_t two_one_two_len = sizeof(two_one_two) / sizeof(two_one_two[0]); |
| 1364 EXPECT(two_one_two_str.Equals(two_one_two, two_one_two_len)); | 1364 EXPECT(two_one_two_str.Equals(two_one_two, two_one_two_len)); |
| 1365 } | 1365 } |
| 1366 } | 1366 } |
| 1367 | 1367 |
| 1368 | 1368 |
| 1369 TEST_CASE(StringHashConcat) { | 1369 VM_TEST_CASE(StringHashConcat) { |
| 1370 EXPECT_EQ(String::Handle(String::New("onebyte")).Hash(), | 1370 EXPECT_EQ(String::Handle(String::New("onebyte")).Hash(), |
| 1371 String::HashConcat(String::Handle(String::New("one")), | 1371 String::HashConcat(String::Handle(String::New("one")), |
| 1372 String::Handle(String::New("byte")))); | 1372 String::Handle(String::New("byte")))); |
| 1373 uint16_t clef_utf16[] = { 0xD834, 0xDD1E }; | 1373 uint16_t clef_utf16[] = { 0xD834, 0xDD1E }; |
| 1374 const String& clef = String::Handle(String::FromUTF16(clef_utf16, 2)); | 1374 const String& clef = String::Handle(String::FromUTF16(clef_utf16, 2)); |
| 1375 int32_t clef_utf32[] = { 0x1D11E }; | 1375 int32_t clef_utf32[] = { 0x1D11E }; |
| 1376 EXPECT(clef.Equals(clef_utf32, 1)); | 1376 EXPECT(clef.Equals(clef_utf32, 1)); |
| 1377 intptr_t hash32 = String::Hash(clef_utf32, 1); | 1377 intptr_t hash32 = String::Hash(clef_utf32, 1); |
| 1378 EXPECT_EQ(hash32, clef.Hash()); | 1378 EXPECT_EQ(hash32, clef.Hash()); |
| 1379 EXPECT_EQ(hash32, String::HashConcat( | 1379 EXPECT_EQ(hash32, String::HashConcat( |
| 1380 String::Handle(String::FromUTF16(clef_utf16, 1)), | 1380 String::Handle(String::FromUTF16(clef_utf16, 1)), |
| 1381 String::Handle(String::FromUTF16(clef_utf16 + 1, 1)))); | 1381 String::Handle(String::FromUTF16(clef_utf16 + 1, 1)))); |
| 1382 } | 1382 } |
| 1383 | 1383 |
| 1384 | 1384 |
| 1385 TEST_CASE(StringSubStringDifferentWidth) { | 1385 VM_TEST_CASE(StringSubStringDifferentWidth) { |
| 1386 // Create 1-byte substring from a 1-byte source string. | 1386 // Create 1-byte substring from a 1-byte source string. |
| 1387 const char* onechars = | 1387 const char* onechars = |
| 1388 "\xC3\xB6\xC3\xB1\xC3\xA9"; | 1388 "\xC3\xB6\xC3\xB1\xC3\xA9"; |
| 1389 | 1389 |
| 1390 const String& onestr = String::Handle(String::New(onechars)); | 1390 const String& onestr = String::Handle(String::New(onechars)); |
| 1391 EXPECT(!onestr.IsNull()); | 1391 EXPECT(!onestr.IsNull()); |
| 1392 EXPECT(onestr.IsOneByteString()); | 1392 EXPECT(onestr.IsOneByteString()); |
| 1393 EXPECT(!onestr.IsTwoByteString()); | 1393 EXPECT(!onestr.IsTwoByteString()); |
| 1394 | 1394 |
| 1395 const String& onesub = String::Handle(String::SubString(onestr, 0)); | 1395 const String& onesub = String::Handle(String::SubString(onestr, 0)); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1437 EXPECT(foursub2.IsTwoByteString()); | 1437 EXPECT(foursub2.IsTwoByteString()); |
| 1438 EXPECT_EQ(foursub2.Length(), 3); | 1438 EXPECT_EQ(foursub2.Length(), 3); |
| 1439 | 1439 |
| 1440 const String& foursub4 = String::Handle(String::SubString(fourstr, 6)); | 1440 const String& foursub4 = String::Handle(String::SubString(fourstr, 6)); |
| 1441 EXPECT_EQ(foursub4.Length(), 8); | 1441 EXPECT_EQ(foursub4.Length(), 8); |
| 1442 EXPECT(!foursub4.IsNull()); | 1442 EXPECT(!foursub4.IsNull()); |
| 1443 EXPECT(foursub4.IsTwoByteString()); | 1443 EXPECT(foursub4.IsTwoByteString()); |
| 1444 } | 1444 } |
| 1445 | 1445 |
| 1446 | 1446 |
| 1447 TEST_CASE(StringFromUtf8Literal) { | 1447 VM_TEST_CASE(StringFromUtf8Literal) { |
| 1448 // Create a 1-byte string from a UTF-8 encoded string literal. | 1448 // Create a 1-byte string from a UTF-8 encoded string literal. |
| 1449 { | 1449 { |
| 1450 const char* src = | 1450 const char* src = |
| 1451 "\xC2\xA0\xC2\xA1\xC2\xA2\xC2\xA3" | 1451 "\xC2\xA0\xC2\xA1\xC2\xA2\xC2\xA3" |
| 1452 "\xC2\xA4\xC2\xA5\xC2\xA6\xC2\xA7" | 1452 "\xC2\xA4\xC2\xA5\xC2\xA6\xC2\xA7" |
| 1453 "\xC2\xA8\xC2\xA9\xC2\xAA\xC2\xAB" | 1453 "\xC2\xA8\xC2\xA9\xC2\xAA\xC2\xAB" |
| 1454 "\xC2\xAC\xC2\xAD\xC2\xAE\xC2\xAF" | 1454 "\xC2\xAC\xC2\xAD\xC2\xAE\xC2\xAF" |
| 1455 "\xC2\xB0\xC2\xB1\xC2\xB2\xC2\xB3" | 1455 "\xC2\xB0\xC2\xB1\xC2\xB2\xC2\xB3" |
| 1456 "\xC2\xB4\xC2\xB5\xC2\xB6\xC2\xB7" | 1456 "\xC2\xB4\xC2\xB5\xC2\xB6\xC2\xB7" |
| 1457 "\xC2\xB8\xC2\xB9\xC2\xBA\xC2\xBB" | 1457 "\xC2\xB8\xC2\xB9\xC2\xBA\xC2\xBB" |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1605 EXPECT(str.IsTwoByteString()); | 1605 EXPECT(str.IsTwoByteString()); |
| 1606 intptr_t expected_size = sizeof(expected) / sizeof(expected[0]); | 1606 intptr_t expected_size = sizeof(expected) / sizeof(expected[0]); |
| 1607 EXPECT_EQ(expected_size, str.Length()); | 1607 EXPECT_EQ(expected_size, str.Length()); |
| 1608 for (int i = 0; i < str.Length(); ++i) { | 1608 for (int i = 0; i < str.Length(); ++i) { |
| 1609 EXPECT_EQ(expected[i], str.CharAt(i)); | 1609 EXPECT_EQ(expected[i], str.CharAt(i)); |
| 1610 } | 1610 } |
| 1611 } | 1611 } |
| 1612 } | 1612 } |
| 1613 | 1613 |
| 1614 | 1614 |
| 1615 TEST_CASE(StringEqualsUtf8) { | 1615 VM_TEST_CASE(StringEqualsUtf8) { |
| 1616 const char* onesrc = "abc"; | 1616 const char* onesrc = "abc"; |
| 1617 const String& onestr = String::Handle(String::New(onesrc)); | 1617 const String& onestr = String::Handle(String::New(onesrc)); |
| 1618 EXPECT(onestr.IsOneByteString()); | 1618 EXPECT(onestr.IsOneByteString()); |
| 1619 EXPECT(!onestr.Equals("")); | 1619 EXPECT(!onestr.Equals("")); |
| 1620 EXPECT(!onestr.Equals("a")); | 1620 EXPECT(!onestr.Equals("a")); |
| 1621 EXPECT(!onestr.Equals("ab")); | 1621 EXPECT(!onestr.Equals("ab")); |
| 1622 EXPECT(onestr.Equals("abc")); | 1622 EXPECT(onestr.Equals("abc")); |
| 1623 EXPECT(!onestr.Equals("abcd")); | 1623 EXPECT(!onestr.Equals("abcd")); |
| 1624 | 1624 |
| 1625 const char* twosrc = "\xD7\x90\xD7\x91\xD7\x92"; | 1625 const char* twosrc = "\xD7\x90\xD7\x91\xD7\x92"; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1636 EXPECT(fourstr.IsTwoByteString()); | 1636 EXPECT(fourstr.IsTwoByteString()); |
| 1637 EXPECT(!fourstr.Equals("")); | 1637 EXPECT(!fourstr.Equals("")); |
| 1638 EXPECT(!fourstr.Equals("\xF0\x90\x8E\xA0")); | 1638 EXPECT(!fourstr.Equals("\xF0\x90\x8E\xA0")); |
| 1639 EXPECT(!fourstr.Equals("\xF0\x90\x8E\xA0\xF0\x90\x8E\xA1")); | 1639 EXPECT(!fourstr.Equals("\xF0\x90\x8E\xA0\xF0\x90\x8E\xA1")); |
| 1640 EXPECT(fourstr.Equals("\xF0\x90\x8E\xA0\xF0\x90\x8E\xA1\xF0\x90\x8E\xA2")); | 1640 EXPECT(fourstr.Equals("\xF0\x90\x8E\xA0\xF0\x90\x8E\xA1\xF0\x90\x8E\xA2")); |
| 1641 EXPECT(!fourstr.Equals("\xF0\x90\x8E\xA0\xF0\x90\x8E\xA1" | 1641 EXPECT(!fourstr.Equals("\xF0\x90\x8E\xA0\xF0\x90\x8E\xA1" |
| 1642 "\xF0\x90\x8E\xA2\xF0\x90\x8E\xA3")); | 1642 "\xF0\x90\x8E\xA2\xF0\x90\x8E\xA3")); |
| 1643 } | 1643 } |
| 1644 | 1644 |
| 1645 | 1645 |
| 1646 TEST_CASE(StringEqualsUTF32) { | 1646 VM_TEST_CASE(StringEqualsUTF32) { |
| 1647 const String& empty = String::Handle(String::New("")); | 1647 const String& empty = String::Handle(String::New("")); |
| 1648 const String& t_str = String::Handle(String::New("t")); | 1648 const String& t_str = String::Handle(String::New("t")); |
| 1649 const String& th_str = String::Handle(String::New("th")); | 1649 const String& th_str = String::Handle(String::New("th")); |
| 1650 const int32_t chars[] = {'t', 'h', 'i', 's'}; | 1650 const int32_t chars[] = {'t', 'h', 'i', 's'}; |
| 1651 EXPECT(!empty.Equals(chars, -1)); | 1651 EXPECT(!empty.Equals(chars, -1)); |
| 1652 EXPECT(empty.Equals(chars, 0)); | 1652 EXPECT(empty.Equals(chars, 0)); |
| 1653 EXPECT(!empty.Equals(chars, 1)); | 1653 EXPECT(!empty.Equals(chars, 1)); |
| 1654 EXPECT(!t_str.Equals(chars, 0)); | 1654 EXPECT(!t_str.Equals(chars, 0)); |
| 1655 EXPECT(t_str.Equals(chars, 1)); | 1655 EXPECT(t_str.Equals(chars, 1)); |
| 1656 EXPECT(!t_str.Equals(chars, 2)); | 1656 EXPECT(!t_str.Equals(chars, 2)); |
| 1657 EXPECT(!th_str.Equals(chars, 1)); | 1657 EXPECT(!th_str.Equals(chars, 1)); |
| 1658 EXPECT(th_str.Equals(chars, 2)); | 1658 EXPECT(th_str.Equals(chars, 2)); |
| 1659 EXPECT(!th_str.Equals(chars, 3)); | 1659 EXPECT(!th_str.Equals(chars, 3)); |
| 1660 } | 1660 } |
| 1661 | 1661 |
| 1662 | 1662 |
| 1663 TEST_CASE(ExternalOneByteString) { | 1663 VM_TEST_CASE(ExternalOneByteString) { |
| 1664 uint8_t characters[] = { 0xF6, 0xF1, 0xE9 }; | 1664 uint8_t characters[] = { 0xF6, 0xF1, 0xE9 }; |
| 1665 intptr_t len = ARRAY_SIZE(characters); | 1665 intptr_t len = ARRAY_SIZE(characters); |
| 1666 | 1666 |
| 1667 const String& str = | 1667 const String& str = |
| 1668 String::Handle( | 1668 String::Handle( |
| 1669 ExternalOneByteString::New(characters, len, NULL, NULL, Heap::kNew)); | 1669 ExternalOneByteString::New(characters, len, NULL, NULL, Heap::kNew)); |
| 1670 EXPECT(!str.IsOneByteString()); | 1670 EXPECT(!str.IsOneByteString()); |
| 1671 EXPECT(str.IsExternalOneByteString()); | 1671 EXPECT(str.IsExternalOneByteString()); |
| 1672 EXPECT_EQ(str.Length(), len); | 1672 EXPECT_EQ(str.Length(), len); |
| 1673 EXPECT(str.Equals("\xC3\xB6\xC3\xB1\xC3\xA9")); | 1673 EXPECT(str.Equals("\xC3\xB6\xC3\xB1\xC3\xA9")); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1685 EXPECT(concat.Equals("\xC3\xB6\xC3\xB1\xC3\xA9\xC3\xB6\xC3\xB1\xC3\xA9")); | 1685 EXPECT(concat.Equals("\xC3\xB6\xC3\xB1\xC3\xA9\xC3\xB6\xC3\xB1\xC3\xA9")); |
| 1686 | 1686 |
| 1687 const String& substr = String::Handle(String::SubString(str, 1, 1)); | 1687 const String& substr = String::Handle(String::SubString(str, 1, 1)); |
| 1688 EXPECT(!substr.IsExternalOneByteString()); | 1688 EXPECT(!substr.IsExternalOneByteString()); |
| 1689 EXPECT(substr.IsOneByteString()); | 1689 EXPECT(substr.IsOneByteString()); |
| 1690 EXPECT_EQ(1, substr.Length()); | 1690 EXPECT_EQ(1, substr.Length()); |
| 1691 EXPECT(substr.Equals("\xC3\xB1")); | 1691 EXPECT(substr.Equals("\xC3\xB1")); |
| 1692 } | 1692 } |
| 1693 | 1693 |
| 1694 | 1694 |
| 1695 TEST_CASE(EscapeSpecialCharactersOneByteString) { | 1695 VM_TEST_CASE(EscapeSpecialCharactersOneByteString) { |
| 1696 uint8_t characters[] = | 1696 uint8_t characters[] = |
| 1697 { 'a', '\n', '\f', '\b', '\t', '\v', '\r', '\\', '$', 'z' }; | 1697 { 'a', '\n', '\f', '\b', '\t', '\v', '\r', '\\', '$', 'z' }; |
| 1698 intptr_t len = ARRAY_SIZE(characters); | 1698 intptr_t len = ARRAY_SIZE(characters); |
| 1699 | 1699 |
| 1700 const String& str = | 1700 const String& str = |
| 1701 String::Handle( | 1701 String::Handle( |
| 1702 OneByteString::New(characters, len, Heap::kNew)); | 1702 OneByteString::New(characters, len, Heap::kNew)); |
| 1703 EXPECT(str.IsOneByteString()); | 1703 EXPECT(str.IsOneByteString()); |
| 1704 EXPECT_EQ(str.Length(), len); | 1704 EXPECT_EQ(str.Length(), len); |
| 1705 EXPECT(str.Equals("a\n\f\b\t\v\r\\$z")); | 1705 EXPECT(str.Equals("a\n\f\b\t\v\r\\$z")); |
| 1706 const String& escaped_str = | 1706 const String& escaped_str = |
| 1707 String::Handle(String::EscapeSpecialCharacters(str)); | 1707 String::Handle(String::EscapeSpecialCharacters(str)); |
| 1708 EXPECT(escaped_str.Equals("a\\n\\f\\b\\t\\v\\r\\\\\\$z")); | 1708 EXPECT(escaped_str.Equals("a\\n\\f\\b\\t\\v\\r\\\\\\$z")); |
| 1709 | 1709 |
| 1710 const String& escaped_empty_str = | 1710 const String& escaped_empty_str = |
| 1711 String::Handle(String::EscapeSpecialCharacters(Symbols::Empty())); | 1711 String::Handle(String::EscapeSpecialCharacters(Symbols::Empty())); |
| 1712 EXPECT_EQ(escaped_empty_str.Length(), 0); | 1712 EXPECT_EQ(escaped_empty_str.Length(), 0); |
| 1713 } | 1713 } |
| 1714 | 1714 |
| 1715 | 1715 |
| 1716 TEST_CASE(EscapeSpecialCharactersExternalOneByteString) { | 1716 VM_TEST_CASE(EscapeSpecialCharactersExternalOneByteString) { |
| 1717 uint8_t characters[] = | 1717 uint8_t characters[] = |
| 1718 { 'a', '\n', '\f', '\b', '\t', '\v', '\r', '\\', '$', 'z' }; | 1718 { 'a', '\n', '\f', '\b', '\t', '\v', '\r', '\\', '$', 'z' }; |
| 1719 intptr_t len = ARRAY_SIZE(characters); | 1719 intptr_t len = ARRAY_SIZE(characters); |
| 1720 | 1720 |
| 1721 const String& str = | 1721 const String& str = |
| 1722 String::Handle( | 1722 String::Handle( |
| 1723 ExternalOneByteString::New(characters, len, NULL, NULL, Heap::kNew)); | 1723 ExternalOneByteString::New(characters, len, NULL, NULL, Heap::kNew)); |
| 1724 EXPECT(!str.IsOneByteString()); | 1724 EXPECT(!str.IsOneByteString()); |
| 1725 EXPECT(str.IsExternalOneByteString()); | 1725 EXPECT(str.IsExternalOneByteString()); |
| 1726 EXPECT_EQ(str.Length(), len); | 1726 EXPECT_EQ(str.Length(), len); |
| 1727 EXPECT(str.Equals("a\n\f\b\t\v\r\\$z")); | 1727 EXPECT(str.Equals("a\n\f\b\t\v\r\\$z")); |
| 1728 const String& escaped_str = | 1728 const String& escaped_str = |
| 1729 String::Handle(String::EscapeSpecialCharacters(str)); | 1729 String::Handle(String::EscapeSpecialCharacters(str)); |
| 1730 EXPECT(escaped_str.Equals("a\\n\\f\\b\\t\\v\\r\\\\\\$z")); | 1730 EXPECT(escaped_str.Equals("a\\n\\f\\b\\t\\v\\r\\\\\\$z")); |
| 1731 | 1731 |
| 1732 const String& empty_str = | 1732 const String& empty_str = |
| 1733 String::Handle( | 1733 String::Handle( |
| 1734 ExternalOneByteString::New(characters, 0, NULL, NULL, Heap::kNew)); | 1734 ExternalOneByteString::New(characters, 0, NULL, NULL, Heap::kNew)); |
| 1735 const String& escaped_empty_str = | 1735 const String& escaped_empty_str = |
| 1736 String::Handle(String::EscapeSpecialCharacters(empty_str)); | 1736 String::Handle(String::EscapeSpecialCharacters(empty_str)); |
| 1737 EXPECT_EQ(empty_str.Length(), 0); | 1737 EXPECT_EQ(empty_str.Length(), 0); |
| 1738 EXPECT_EQ(escaped_empty_str.Length(), 0); | 1738 EXPECT_EQ(escaped_empty_str.Length(), 0); |
| 1739 } | 1739 } |
| 1740 | 1740 |
| 1741 TEST_CASE(EscapeSpecialCharactersTwoByteString) { | 1741 VM_TEST_CASE(EscapeSpecialCharactersTwoByteString) { |
| 1742 uint16_t characters[] = | 1742 uint16_t characters[] = |
| 1743 { 'a', '\n', '\f', '\b', '\t', '\v', '\r', '\\', '$', 'z' }; | 1743 { 'a', '\n', '\f', '\b', '\t', '\v', '\r', '\\', '$', 'z' }; |
| 1744 intptr_t len = ARRAY_SIZE(characters); | 1744 intptr_t len = ARRAY_SIZE(characters); |
| 1745 | 1745 |
| 1746 const String& str = | 1746 const String& str = |
| 1747 String::Handle(TwoByteString::New(characters, len, Heap::kNew)); | 1747 String::Handle(TwoByteString::New(characters, len, Heap::kNew)); |
| 1748 EXPECT(str.IsTwoByteString()); | 1748 EXPECT(str.IsTwoByteString()); |
| 1749 EXPECT_EQ(str.Length(), len); | 1749 EXPECT_EQ(str.Length(), len); |
| 1750 EXPECT(str.Equals("a\n\f\b\t\v\r\\$z")); | 1750 EXPECT(str.Equals("a\n\f\b\t\v\r\\$z")); |
| 1751 const String& escaped_str = | 1751 const String& escaped_str = |
| 1752 String::Handle(String::EscapeSpecialCharacters(str)); | 1752 String::Handle(String::EscapeSpecialCharacters(str)); |
| 1753 EXPECT(escaped_str.Equals("a\\n\\f\\b\\t\\v\\r\\\\\\$z")); | 1753 EXPECT(escaped_str.Equals("a\\n\\f\\b\\t\\v\\r\\\\\\$z")); |
| 1754 | 1754 |
| 1755 const String& empty_str = | 1755 const String& empty_str = |
| 1756 String::Handle(TwoByteString::New(static_cast<intptr_t>(0), Heap::kNew)); | 1756 String::Handle(TwoByteString::New(static_cast<intptr_t>(0), Heap::kNew)); |
| 1757 const String& escaped_empty_str = | 1757 const String& escaped_empty_str = |
| 1758 String::Handle(String::EscapeSpecialCharacters(empty_str)); | 1758 String::Handle(String::EscapeSpecialCharacters(empty_str)); |
| 1759 EXPECT_EQ(empty_str.Length(), 0); | 1759 EXPECT_EQ(empty_str.Length(), 0); |
| 1760 EXPECT_EQ(escaped_empty_str.Length(), 0); | 1760 EXPECT_EQ(escaped_empty_str.Length(), 0); |
| 1761 } | 1761 } |
| 1762 | 1762 |
| 1763 | 1763 |
| 1764 TEST_CASE(EscapeSpecialCharactersExternalTwoByteString) { | 1764 VM_TEST_CASE(EscapeSpecialCharactersExternalTwoByteString) { |
| 1765 uint16_t characters[] = | 1765 uint16_t characters[] = |
| 1766 { 'a', '\n', '\f', '\b', '\t', '\v', '\r', '\\', '$', 'z' }; | 1766 { 'a', '\n', '\f', '\b', '\t', '\v', '\r', '\\', '$', 'z' }; |
| 1767 intptr_t len = ARRAY_SIZE(characters); | 1767 intptr_t len = ARRAY_SIZE(characters); |
| 1768 | 1768 |
| 1769 const String& str = | 1769 const String& str = |
| 1770 String::Handle( | 1770 String::Handle( |
| 1771 ExternalTwoByteString::New(characters, len, NULL, NULL, Heap::kNew)); | 1771 ExternalTwoByteString::New(characters, len, NULL, NULL, Heap::kNew)); |
| 1772 EXPECT(str.IsExternalTwoByteString()); | 1772 EXPECT(str.IsExternalTwoByteString()); |
| 1773 EXPECT_EQ(str.Length(), len); | 1773 EXPECT_EQ(str.Length(), len); |
| 1774 EXPECT(str.Equals("a\n\f\b\t\v\r\\$z")); | 1774 EXPECT(str.Equals("a\n\f\b\t\v\r\\$z")); |
| 1775 const String& escaped_str = | 1775 const String& escaped_str = |
| 1776 String::Handle(String::EscapeSpecialCharacters(str)); | 1776 String::Handle(String::EscapeSpecialCharacters(str)); |
| 1777 EXPECT(escaped_str.Equals("a\\n\\f\\b\\t\\v\\r\\\\\\$z")); | 1777 EXPECT(escaped_str.Equals("a\\n\\f\\b\\t\\v\\r\\\\\\$z")); |
| 1778 | 1778 |
| 1779 const String& empty_str = | 1779 const String& empty_str = |
| 1780 String::Handle( | 1780 String::Handle( |
| 1781 ExternalTwoByteString::New(characters, 0, NULL, NULL, Heap::kNew)); | 1781 ExternalTwoByteString::New(characters, 0, NULL, NULL, Heap::kNew)); |
| 1782 const String& escaped_empty_str = | 1782 const String& escaped_empty_str = |
| 1783 String::Handle(String::EscapeSpecialCharacters(empty_str)); | 1783 String::Handle(String::EscapeSpecialCharacters(empty_str)); |
| 1784 EXPECT_EQ(empty_str.Length(), 0); | 1784 EXPECT_EQ(empty_str.Length(), 0); |
| 1785 EXPECT_EQ(escaped_empty_str.Length(), 0); | 1785 EXPECT_EQ(escaped_empty_str.Length(), 0); |
| 1786 } | 1786 } |
| 1787 | 1787 |
| 1788 | 1788 |
| 1789 TEST_CASE(ExternalTwoByteString) { | 1789 VM_TEST_CASE(ExternalTwoByteString) { |
| 1790 uint16_t characters[] = { 0x1E6B, 0x1E85, 0x1E53 }; | 1790 uint16_t characters[] = { 0x1E6B, 0x1E85, 0x1E53 }; |
| 1791 intptr_t len = ARRAY_SIZE(characters); | 1791 intptr_t len = ARRAY_SIZE(characters); |
| 1792 | 1792 |
| 1793 const String& str = | 1793 const String& str = |
| 1794 String::Handle( | 1794 String::Handle( |
| 1795 ExternalTwoByteString::New(characters, len, NULL, NULL, Heap::kNew)); | 1795 ExternalTwoByteString::New(characters, len, NULL, NULL, Heap::kNew)); |
| 1796 EXPECT(!str.IsTwoByteString()); | 1796 EXPECT(!str.IsTwoByteString()); |
| 1797 EXPECT(str.IsExternalTwoByteString()); | 1797 EXPECT(str.IsExternalTwoByteString()); |
| 1798 EXPECT_EQ(str.Length(), len); | 1798 EXPECT_EQ(str.Length(), len); |
| 1799 EXPECT(str.Equals("\xE1\xB9\xAB\xE1\xBA\x85\xE1\xB9\x93")); | 1799 EXPECT(str.Equals("\xE1\xB9\xAB\xE1\xBA\x85\xE1\xB9\x93")); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1812 "\xE1\xB9\xAB\xE1\xBA\x85\xE1\xB9\x93")); | 1812 "\xE1\xB9\xAB\xE1\xBA\x85\xE1\xB9\x93")); |
| 1813 | 1813 |
| 1814 const String& substr = String::Handle(String::SubString(str, 1, 1)); | 1814 const String& substr = String::Handle(String::SubString(str, 1, 1)); |
| 1815 EXPECT(!substr.IsExternalTwoByteString()); | 1815 EXPECT(!substr.IsExternalTwoByteString()); |
| 1816 EXPECT(substr.IsTwoByteString()); | 1816 EXPECT(substr.IsTwoByteString()); |
| 1817 EXPECT_EQ(1, substr.Length()); | 1817 EXPECT_EQ(1, substr.Length()); |
| 1818 EXPECT(substr.Equals("\xE1\xBA\x85")); | 1818 EXPECT(substr.Equals("\xE1\xBA\x85")); |
| 1819 } | 1819 } |
| 1820 | 1820 |
| 1821 | 1821 |
| 1822 TEST_CASE(Symbol) { | 1822 VM_TEST_CASE(Symbol) { |
| 1823 const String& one = String::Handle(Symbols::New("Eins")); | 1823 const String& one = String::Handle(Symbols::New("Eins")); |
| 1824 EXPECT(one.IsSymbol()); | 1824 EXPECT(one.IsSymbol()); |
| 1825 const String& two = String::Handle(Symbols::New("Zwei")); | 1825 const String& two = String::Handle(Symbols::New("Zwei")); |
| 1826 const String& three = String::Handle(Symbols::New("Drei")); | 1826 const String& three = String::Handle(Symbols::New("Drei")); |
| 1827 const String& four = String::Handle(Symbols::New("Vier")); | 1827 const String& four = String::Handle(Symbols::New("Vier")); |
| 1828 const String& five = String::Handle(Symbols::New("Fuenf")); | 1828 const String& five = String::Handle(Symbols::New("Fuenf")); |
| 1829 const String& six = String::Handle(Symbols::New("Sechs")); | 1829 const String& six = String::Handle(Symbols::New("Sechs")); |
| 1830 const String& seven = String::Handle(Symbols::New("Sieben")); | 1830 const String& seven = String::Handle(Symbols::New("Sieben")); |
| 1831 const String& eight = String::Handle(Symbols::New("Acht")); | 1831 const String& eight = String::Handle(Symbols::New("Acht")); |
| 1832 const String& nine = String::Handle(Symbols::New("Neun")); | 1832 const String& nine = String::Handle(Symbols::New("Neun")); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1874 String& elf1 = String::Handle(Symbols::FromUTF16(char16, 3)); | 1874 String& elf1 = String::Handle(Symbols::FromUTF16(char16, 3)); |
| 1875 int32_t char32[] = { 'E', 'l', 'f' }; | 1875 int32_t char32[] = { 'E', 'l', 'f' }; |
| 1876 String& elf2 = String::Handle(Symbols::FromUTF32(char32, 3)); | 1876 String& elf2 = String::Handle(Symbols::FromUTF32(char32, 3)); |
| 1877 EXPECT(elf1.IsSymbol()); | 1877 EXPECT(elf1.IsSymbol()); |
| 1878 EXPECT(elf2.IsSymbol()); | 1878 EXPECT(elf2.IsSymbol()); |
| 1879 EXPECT_EQ(elf1.raw(), Symbols::New("Elf")); | 1879 EXPECT_EQ(elf1.raw(), Symbols::New("Elf")); |
| 1880 EXPECT_EQ(elf2.raw(), Symbols::New("Elf")); | 1880 EXPECT_EQ(elf2.raw(), Symbols::New("Elf")); |
| 1881 } | 1881 } |
| 1882 | 1882 |
| 1883 | 1883 |
| 1884 TEST_CASE(SymbolUnicode) { | 1884 VM_TEST_CASE(SymbolUnicode) { |
| 1885 uint16_t monkey_utf16[] = { 0xd83d, 0xdc35 }; // Unicode Monkey Face. | 1885 uint16_t monkey_utf16[] = { 0xd83d, 0xdc35 }; // Unicode Monkey Face. |
| 1886 String& monkey = String::Handle(Symbols::FromUTF16(monkey_utf16, 2)); | 1886 String& monkey = String::Handle(Symbols::FromUTF16(monkey_utf16, 2)); |
| 1887 EXPECT(monkey.IsSymbol()); | 1887 EXPECT(monkey.IsSymbol()); |
| 1888 const char monkey_utf8[] = {'\xf0', '\x9f', '\x90', '\xb5', 0}; | 1888 const char monkey_utf8[] = {'\xf0', '\x9f', '\x90', '\xb5', 0}; |
| 1889 EXPECT_EQ(monkey.raw(), Symbols::New(monkey_utf8)); | 1889 EXPECT_EQ(monkey.raw(), Symbols::New(monkey_utf8)); |
| 1890 | 1890 |
| 1891 int32_t kMonkeyFace = 0x1f435; | 1891 int32_t kMonkeyFace = 0x1f435; |
| 1892 String& monkey2 = String::Handle(Symbols::FromCharCode(kMonkeyFace)); | 1892 String& monkey2 = String::Handle(Symbols::FromCharCode(kMonkeyFace)); |
| 1893 EXPECT_EQ(monkey.raw(), monkey2.raw()); | 1893 EXPECT_EQ(monkey.raw(), monkey2.raw()); |
| 1894 | 1894 |
| 1895 // Unicode cat face with tears of joy. | 1895 // Unicode cat face with tears of joy. |
| 1896 int32_t kCatFaceWithTearsOfJoy = 0x1f639; | 1896 int32_t kCatFaceWithTearsOfJoy = 0x1f639; |
| 1897 String& cat = String::Handle(Symbols::FromCharCode(kCatFaceWithTearsOfJoy)); | 1897 String& cat = String::Handle(Symbols::FromCharCode(kCatFaceWithTearsOfJoy)); |
| 1898 | 1898 |
| 1899 uint16_t cat_utf16[] = { 0xd83d, 0xde39 }; | 1899 uint16_t cat_utf16[] = { 0xd83d, 0xde39 }; |
| 1900 String& cat2 = String::Handle(Symbols::FromUTF16(cat_utf16, 2)); | 1900 String& cat2 = String::Handle(Symbols::FromUTF16(cat_utf16, 2)); |
| 1901 EXPECT(cat2.IsSymbol()); | 1901 EXPECT(cat2.IsSymbol()); |
| 1902 EXPECT_EQ(cat2.raw(), cat.raw()); | 1902 EXPECT_EQ(cat2.raw(), cat.raw()); |
| 1903 } | 1903 } |
| 1904 | 1904 |
| 1905 | 1905 |
| 1906 TEST_CASE(Bool) { | 1906 VM_TEST_CASE(Bool) { |
| 1907 EXPECT(Bool::True().value()); | 1907 EXPECT(Bool::True().value()); |
| 1908 EXPECT(!Bool::False().value()); | 1908 EXPECT(!Bool::False().value()); |
| 1909 } | 1909 } |
| 1910 | 1910 |
| 1911 | 1911 |
| 1912 TEST_CASE(Array) { | 1912 VM_TEST_CASE(Array) { |
| 1913 const int kArrayLen = 5; | 1913 const int kArrayLen = 5; |
| 1914 const Array& array = Array::Handle(Array::New(kArrayLen)); | 1914 const Array& array = Array::Handle(Array::New(kArrayLen)); |
| 1915 EXPECT_EQ(kArrayLen, array.Length()); | 1915 EXPECT_EQ(kArrayLen, array.Length()); |
| 1916 Object& element = Object::Handle(array.At(0)); | 1916 Object& element = Object::Handle(array.At(0)); |
| 1917 EXPECT(element.IsNull()); | 1917 EXPECT(element.IsNull()); |
| 1918 element = array.At(kArrayLen - 1); | 1918 element = array.At(kArrayLen - 1); |
| 1919 EXPECT(element.IsNull()); | 1919 EXPECT(element.IsNull()); |
| 1920 array.SetAt(0, array); | 1920 array.SetAt(0, array); |
| 1921 array.SetAt(2, array); | 1921 array.SetAt(2, array); |
| 1922 element = array.At(0); | 1922 element = array.At(0); |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2049 if (Dart_IsError(result)) { | 2049 if (Dart_IsError(result)) { |
| 2050 EXPECT_ERROR(result, "Out of Memory"); | 2050 EXPECT_ERROR(result, "Out of Memory"); |
| 2051 } else { | 2051 } else { |
| 2052 intptr_t actual = 0; | 2052 intptr_t actual = 0; |
| 2053 EXPECT_VALID(Dart_ListLength(result, &actual)); | 2053 EXPECT_VALID(Dart_ListLength(result, &actual)); |
| 2054 EXPECT_EQ(max_elements, actual); | 2054 EXPECT_EQ(max_elements, actual); |
| 2055 } | 2055 } |
| 2056 } | 2056 } |
| 2057 | 2057 |
| 2058 | 2058 |
| 2059 TEST_CASE(StringCodePointIterator) { | 2059 VM_TEST_CASE(StringCodePointIterator) { |
| 2060 const String& str0 = String::Handle(String::New("")); | 2060 const String& str0 = String::Handle(String::New("")); |
| 2061 String::CodePointIterator it0(str0); | 2061 String::CodePointIterator it0(str0); |
| 2062 EXPECT(!it0.Next()); | 2062 EXPECT(!it0.Next()); |
| 2063 | 2063 |
| 2064 const String& str1 = String::Handle(String::New(" \xc3\xa7 ")); | 2064 const String& str1 = String::Handle(String::New(" \xc3\xa7 ")); |
| 2065 String::CodePointIterator it1(str1); | 2065 String::CodePointIterator it1(str1); |
| 2066 EXPECT(it1.Next()); | 2066 EXPECT(it1.Next()); |
| 2067 EXPECT_EQ(' ', it1.Current()); | 2067 EXPECT_EQ(' ', it1.Current()); |
| 2068 EXPECT(it1.Next()); | 2068 EXPECT(it1.Next()); |
| 2069 EXPECT_EQ(0xE7, it1.Current()); | 2069 EXPECT_EQ(0xE7, it1.Current()); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2104 EXPECT(it3.Next()); | 2104 EXPECT(it3.Next()); |
| 2105 EXPECT_EQ(0x1D461, it3.Current()); | 2105 EXPECT_EQ(0x1D461, it3.Current()); |
| 2106 EXPECT(it3.Next()); | 2106 EXPECT(it3.Next()); |
| 2107 EXPECT_EQ(0x1D462, it3.Current()); | 2107 EXPECT_EQ(0x1D462, it3.Current()); |
| 2108 EXPECT(it3.Next()); | 2108 EXPECT(it3.Next()); |
| 2109 EXPECT_EQ(0x1D463, it3.Current()); | 2109 EXPECT_EQ(0x1D463, it3.Current()); |
| 2110 EXPECT(!it3.Next()); | 2110 EXPECT(!it3.Next()); |
| 2111 } | 2111 } |
| 2112 | 2112 |
| 2113 | 2113 |
| 2114 TEST_CASE(StringCodePointIteratorRange) { | 2114 VM_TEST_CASE(StringCodePointIteratorRange) { |
| 2115 const String& str = String::Handle(String::New("foo bar baz")); | 2115 const String& str = String::Handle(String::New("foo bar baz")); |
| 2116 | 2116 |
| 2117 String::CodePointIterator it0(str, 3, 0); | 2117 String::CodePointIterator it0(str, 3, 0); |
| 2118 EXPECT(!it0.Next()); | 2118 EXPECT(!it0.Next()); |
| 2119 | 2119 |
| 2120 String::CodePointIterator it1(str, 4, 3); | 2120 String::CodePointIterator it1(str, 4, 3); |
| 2121 EXPECT(it1.Next()); | 2121 EXPECT(it1.Next()); |
| 2122 EXPECT_EQ('b', it1.Current()); | 2122 EXPECT_EQ('b', it1.Current()); |
| 2123 EXPECT(it1.Next()); | 2123 EXPECT(it1.Next()); |
| 2124 EXPECT_EQ('a', it1.Current()); | 2124 EXPECT_EQ('a', it1.Current()); |
| 2125 EXPECT(it1.Next()); | 2125 EXPECT(it1.Next()); |
| 2126 EXPECT_EQ('r', it1.Current()); | 2126 EXPECT_EQ('r', it1.Current()); |
| 2127 EXPECT(!it1.Next()); | 2127 EXPECT(!it1.Next()); |
| 2128 } | 2128 } |
| 2129 | 2129 |
| 2130 | 2130 |
| 2131 TEST_CASE(GrowableObjectArray) { | 2131 VM_TEST_CASE(GrowableObjectArray) { |
| 2132 const int kArrayLen = 5; | 2132 const int kArrayLen = 5; |
| 2133 Smi& value = Smi::Handle(); | 2133 Smi& value = Smi::Handle(); |
| 2134 Smi& expected_value = Smi::Handle(); | 2134 Smi& expected_value = Smi::Handle(); |
| 2135 GrowableObjectArray& array = GrowableObjectArray::Handle(); | 2135 GrowableObjectArray& array = GrowableObjectArray::Handle(); |
| 2136 | 2136 |
| 2137 // Test basic growing functionality. | 2137 // Test basic growing functionality. |
| 2138 array = GrowableObjectArray::New(kArrayLen); | 2138 array = GrowableObjectArray::New(kArrayLen); |
| 2139 EXPECT_EQ(kArrayLen, array.Capacity()); | 2139 EXPECT_EQ(kArrayLen, array.Capacity()); |
| 2140 EXPECT_EQ(0, array.Length()); | 2140 EXPECT_EQ(0, array.Length()); |
| 2141 for (intptr_t i = 0; i < 10; i++) { | 2141 for (intptr_t i = 0; i < 10; i++) { |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2243 new_array = Array::MakeArray(array); | 2243 new_array = Array::MakeArray(array); |
| 2244 EXPECT_EQ(1, new_array.Length()); | 2244 EXPECT_EQ(1, new_array.Length()); |
| 2245 heap->CollectAllGarbage(); | 2245 heap->CollectAllGarbage(); |
| 2246 intptr_t capacity_after = heap->CapacityInWords(Heap::kOld); | 2246 intptr_t capacity_after = heap->CapacityInWords(Heap::kOld); |
| 2247 // Page should shrink. | 2247 // Page should shrink. |
| 2248 EXPECT_LT(capacity_after, capacity_before); | 2248 EXPECT_LT(capacity_after, capacity_before); |
| 2249 EXPECT_EQ(1, new_array.Length()); | 2249 EXPECT_EQ(1, new_array.Length()); |
| 2250 } | 2250 } |
| 2251 | 2251 |
| 2252 | 2252 |
| 2253 TEST_CASE(InternalTypedData) { | 2253 VM_TEST_CASE(InternalTypedData) { |
| 2254 uint8_t data[] = { 253, 254, 255, 0, 1, 2, 3, 4 }; | 2254 uint8_t data[] = { 253, 254, 255, 0, 1, 2, 3, 4 }; |
| 2255 intptr_t data_length = ARRAY_SIZE(data); | 2255 intptr_t data_length = ARRAY_SIZE(data); |
| 2256 | 2256 |
| 2257 const TypedData& int8_array = | 2257 const TypedData& int8_array = |
| 2258 TypedData::Handle(TypedData::New(kTypedDataInt8ArrayCid, data_length)); | 2258 TypedData::Handle(TypedData::New(kTypedDataInt8ArrayCid, data_length)); |
| 2259 EXPECT(!int8_array.IsNull()); | 2259 EXPECT(!int8_array.IsNull()); |
| 2260 EXPECT_EQ(data_length, int8_array.Length()); | 2260 EXPECT_EQ(data_length, int8_array.Length()); |
| 2261 for (intptr_t i = 0; i < data_length; ++i) { | 2261 for (intptr_t i = 0; i < data_length; ++i) { |
| 2262 int8_array.SetInt8(i, data[i]); | 2262 int8_array.SetInt8(i, data[i]); |
| 2263 } | 2263 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2299 } | 2299 } |
| 2300 for (intptr_t i = 0; i < data_length; ++i) { | 2300 for (intptr_t i = 0; i < data_length; ++i) { |
| 2301 int8_array.SetInt8(i, 123 + i); | 2301 int8_array.SetInt8(i, 123 + i); |
| 2302 } | 2302 } |
| 2303 for (intptr_t i = 0; i < data_length; ++i) { | 2303 for (intptr_t i = 0; i < data_length; ++i) { |
| 2304 EXPECT(int8_array.GetInt8(i) != int8_array2.GetInt8(i)); | 2304 EXPECT(int8_array.GetInt8(i) != int8_array2.GetInt8(i)); |
| 2305 } | 2305 } |
| 2306 } | 2306 } |
| 2307 | 2307 |
| 2308 | 2308 |
| 2309 TEST_CASE(ExternalTypedData) { | 2309 VM_TEST_CASE(ExternalTypedData) { |
| 2310 uint8_t data[] = { 253, 254, 255, 0, 1, 2, 3, 4 }; | 2310 uint8_t data[] = { 253, 254, 255, 0, 1, 2, 3, 4 }; |
| 2311 intptr_t data_length = ARRAY_SIZE(data); | 2311 intptr_t data_length = ARRAY_SIZE(data); |
| 2312 | 2312 |
| 2313 const ExternalTypedData& int8_array = | 2313 const ExternalTypedData& int8_array = |
| 2314 ExternalTypedData::Handle( | 2314 ExternalTypedData::Handle( |
| 2315 ExternalTypedData::New(kExternalTypedDataInt8ArrayCid, | 2315 ExternalTypedData::New(kExternalTypedDataInt8ArrayCid, |
| 2316 data, | 2316 data, |
| 2317 data_length)); | 2317 data_length)); |
| 2318 EXPECT(!int8_array.IsNull()); | 2318 EXPECT(!int8_array.IsNull()); |
| 2319 EXPECT_EQ(data_length, int8_array.Length()); | 2319 EXPECT_EQ(data_length, int8_array.Length()); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2400 Dart_Handle h_lib = TestCase::LoadTestScript(kScript, NULL); | 2400 Dart_Handle h_lib = TestCase::LoadTestScript(kScript, NULL); |
| 2401 EXPECT_VALID(h_lib); | 2401 EXPECT_VALID(h_lib); |
| 2402 Library& lib = Library::Handle(); | 2402 Library& lib = Library::Handle(); |
| 2403 lib ^= Api::UnwrapHandle(h_lib); | 2403 lib ^= Api::UnwrapHandle(h_lib); |
| 2404 EXPECT(!lib.IsNull()); | 2404 EXPECT(!lib.IsNull()); |
| 2405 Dart_Handle result = Dart_Invoke(h_lib, NewString("main"), 0, NULL); | 2405 Dart_Handle result = Dart_Invoke(h_lib, NewString("main"), 0, NULL); |
| 2406 EXPECT_VALID(result); | 2406 EXPECT_VALID(result); |
| 2407 } | 2407 } |
| 2408 | 2408 |
| 2409 | 2409 |
| 2410 TEST_CASE(EmbeddedScript) { | 2410 VM_TEST_CASE(EmbeddedScript) { |
| 2411 const char* url_chars = "builtin:test-case"; | 2411 const char* url_chars = "builtin:test-case"; |
| 2412 const char* text = | 2412 const char* text = |
| 2413 /* 1 */ "<!DOCTYPE html>\n" | 2413 /* 1 */ "<!DOCTYPE html>\n" |
| 2414 /* 2 */ " ... more junk ...\n" | 2414 /* 2 */ " ... more junk ...\n" |
| 2415 /* 3 */ " <script type='application/dart'>main() {\n" | 2415 /* 3 */ " <script type='application/dart'>main() {\n" |
| 2416 /* 4 */ " return 'foo';\n" | 2416 /* 4 */ " return 'foo';\n" |
| 2417 /* 5 */ " }\n" | 2417 /* 5 */ " }\n" |
| 2418 /* 6 */ "</script>\n"; | 2418 /* 6 */ "</script>\n"; |
| 2419 const char* line1 = text; | 2419 const char* line1 = text; |
| 2420 const char* line2 = strstr(line1, "\n") + 1; | 2420 const char* line2 = strstr(line1, "\n") + 1; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2495 EXPECT_EQ(3, last_idx); | 2495 EXPECT_EQ(3, last_idx); |
| 2496 script.TokenRangeAtLine(6, &first_idx, &last_idx); | 2496 script.TokenRangeAtLine(6, &first_idx, &last_idx); |
| 2497 EXPECT_EQ(-1, first_idx); | 2497 EXPECT_EQ(-1, first_idx); |
| 2498 EXPECT_EQ(-1, last_idx); | 2498 EXPECT_EQ(-1, last_idx); |
| 2499 script.TokenRangeAtLine(1000, &first_idx, &last_idx); | 2499 script.TokenRangeAtLine(1000, &first_idx, &last_idx); |
| 2500 EXPECT_EQ(-1, first_idx); | 2500 EXPECT_EQ(-1, first_idx); |
| 2501 EXPECT_EQ(-1, last_idx); | 2501 EXPECT_EQ(-1, last_idx); |
| 2502 } | 2502 } |
| 2503 | 2503 |
| 2504 | 2504 |
| 2505 TEST_CASE(Context) { | 2505 VM_TEST_CASE(Context) { |
| 2506 const int kNumVariables = 5; | 2506 const int kNumVariables = 5; |
| 2507 const Context& parent_context = Context::Handle(Context::New(0)); | 2507 const Context& parent_context = Context::Handle(Context::New(0)); |
| 2508 const Context& context = Context::Handle(Context::New(kNumVariables)); | 2508 const Context& context = Context::Handle(Context::New(kNumVariables)); |
| 2509 context.set_parent(parent_context); | 2509 context.set_parent(parent_context); |
| 2510 EXPECT_EQ(kNumVariables, context.num_variables()); | 2510 EXPECT_EQ(kNumVariables, context.num_variables()); |
| 2511 EXPECT(Context::Handle(context.parent()).raw() == parent_context.raw()); | 2511 EXPECT(Context::Handle(context.parent()).raw() == parent_context.raw()); |
| 2512 EXPECT_EQ(0, Context::Handle(context.parent()).num_variables()); | 2512 EXPECT_EQ(0, Context::Handle(context.parent()).num_variables()); |
| 2513 EXPECT(Context::Handle(Context::Handle(context.parent()).parent()).IsNull()); | 2513 EXPECT(Context::Handle(Context::Handle(context.parent()).parent()).IsNull()); |
| 2514 Object& variable = Object::Handle(context.At(0)); | 2514 Object& variable = Object::Handle(context.At(0)); |
| 2515 EXPECT(variable.IsNull()); | 2515 EXPECT(variable.IsNull()); |
| 2516 variable = context.At(kNumVariables - 1); | 2516 variable = context.At(kNumVariables - 1); |
| 2517 EXPECT(variable.IsNull()); | 2517 EXPECT(variable.IsNull()); |
| 2518 context.SetAt(0, Smi::Handle(Smi::New(2))); | 2518 context.SetAt(0, Smi::Handle(Smi::New(2))); |
| 2519 context.SetAt(2, Smi::Handle(Smi::New(3))); | 2519 context.SetAt(2, Smi::Handle(Smi::New(3))); |
| 2520 Smi& smi = Smi::Handle(); | 2520 Smi& smi = Smi::Handle(); |
| 2521 smi ^= context.At(0); | 2521 smi ^= context.At(0); |
| 2522 EXPECT_EQ(2, smi.Value()); | 2522 EXPECT_EQ(2, smi.Value()); |
| 2523 smi ^= context.At(2); | 2523 smi ^= context.At(2); |
| 2524 EXPECT_EQ(3, smi.Value()); | 2524 EXPECT_EQ(3, smi.Value()); |
| 2525 } | 2525 } |
| 2526 | 2526 |
| 2527 | 2527 |
| 2528 TEST_CASE(ContextScope) { | 2528 VM_TEST_CASE(ContextScope) { |
| 2529 const intptr_t parent_scope_function_level = 0; | 2529 const intptr_t parent_scope_function_level = 0; |
| 2530 LocalScope* parent_scope = | 2530 LocalScope* parent_scope = |
| 2531 new LocalScope(NULL, parent_scope_function_level, 0); | 2531 new LocalScope(NULL, parent_scope_function_level, 0); |
| 2532 | 2532 |
| 2533 const intptr_t local_scope_function_level = 1; | 2533 const intptr_t local_scope_function_level = 1; |
| 2534 LocalScope* local_scope = | 2534 LocalScope* local_scope = |
| 2535 new LocalScope(parent_scope, local_scope_function_level, 0); | 2535 new LocalScope(parent_scope, local_scope_function_level, 0); |
| 2536 | 2536 |
| 2537 const Type& dynamic_type = Type::ZoneHandle(Type::DynamicType()); | 2537 const Type& dynamic_type = Type::ZoneHandle(Type::DynamicType()); |
| 2538 const String& a = String::ZoneHandle(Symbols::New("a")); | 2538 const String& a = String::ZoneHandle(Symbols::New("a")); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2605 EXPECT(outer_scope->LocalLookupVariable(b) == NULL); | 2605 EXPECT(outer_scope->LocalLookupVariable(b) == NULL); |
| 2606 | 2606 |
| 2607 var_c = outer_scope->LocalLookupVariable(c); | 2607 var_c = outer_scope->LocalLookupVariable(c); |
| 2608 EXPECT(var_c->is_captured()); | 2608 EXPECT(var_c->is_captured()); |
| 2609 EXPECT_EQ(1, var_c->index()); | 2609 EXPECT_EQ(1, var_c->index()); |
| 2610 EXPECT_EQ(parent_scope_context_level - local_scope_context_level, | 2610 EXPECT_EQ(parent_scope_context_level - local_scope_context_level, |
| 2611 var_c->owner()->context_level()); // Adjusted context level. | 2611 var_c->owner()->context_level()); // Adjusted context level. |
| 2612 } | 2612 } |
| 2613 | 2613 |
| 2614 | 2614 |
| 2615 TEST_CASE(Closure) { | 2615 VM_TEST_CASE(Closure) { |
| 2616 // Allocate the class first. | 2616 // Allocate the class first. |
| 2617 const String& class_name = String::Handle(Symbols::New("MyClass")); | 2617 const String& class_name = String::Handle(Symbols::New("MyClass")); |
| 2618 const Script& script = Script::Handle(); | 2618 const Script& script = Script::Handle(); |
| 2619 const Class& cls = Class::Handle(CreateDummyClass(class_name, script)); | 2619 const Class& cls = Class::Handle(CreateDummyClass(class_name, script)); |
| 2620 const Array& functions = Array::Handle(Array::New(1)); | 2620 const Array& functions = Array::Handle(Array::New(1)); |
| 2621 | 2621 |
| 2622 const Context& context = Context::Handle(Context::New(0)); | 2622 const Context& context = Context::Handle(Context::New(0)); |
| 2623 Function& parent = Function::Handle(); | 2623 Function& parent = Function::Handle(); |
| 2624 const String& parent_name = String::Handle(Symbols::New("foo_papa")); | 2624 const String& parent_name = String::Handle(Symbols::New("foo_papa")); |
| 2625 parent = Function::New(parent_name, RawFunction::kRegularFunction, | 2625 parent = Function::New(parent_name, RawFunction::kRegularFunction, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 2638 EXPECT(closure_class.IsCanonicalSignatureClass()); | 2638 EXPECT(closure_class.IsCanonicalSignatureClass()); |
| 2639 EXPECT_EQ(closure_class.raw(), signature_class.raw()); | 2639 EXPECT_EQ(closure_class.raw(), signature_class.raw()); |
| 2640 const Function& signature_function = | 2640 const Function& signature_function = |
| 2641 Function::Handle(signature_class.signature_function()); | 2641 Function::Handle(signature_class.signature_function()); |
| 2642 EXPECT_EQ(signature_function.raw(), function.raw()); | 2642 EXPECT_EQ(signature_function.raw(), function.raw()); |
| 2643 const Context& closure_context = Context::Handle(Closure::context(closure)); | 2643 const Context& closure_context = Context::Handle(Closure::context(closure)); |
| 2644 EXPECT_EQ(closure_context.raw(), closure_context.raw()); | 2644 EXPECT_EQ(closure_context.raw(), closure_context.raw()); |
| 2645 } | 2645 } |
| 2646 | 2646 |
| 2647 | 2647 |
| 2648 TEST_CASE(ObjectPrinting) { | 2648 VM_TEST_CASE(ObjectPrinting) { |
| 2649 // Simple Smis. | 2649 // Simple Smis. |
| 2650 EXPECT_STREQ("2", Smi::Handle(Smi::New(2)).ToCString()); | 2650 EXPECT_STREQ("2", Smi::Handle(Smi::New(2)).ToCString()); |
| 2651 EXPECT_STREQ("-15", Smi::Handle(Smi::New(-15)).ToCString()); | 2651 EXPECT_STREQ("-15", Smi::Handle(Smi::New(-15)).ToCString()); |
| 2652 | 2652 |
| 2653 // bool class and true/false values. | 2653 // bool class and true/false values. |
| 2654 ObjectStore* object_store = Isolate::Current()->object_store(); | 2654 ObjectStore* object_store = Isolate::Current()->object_store(); |
| 2655 const Class& bool_class = Class::Handle(object_store->bool_class()); | 2655 const Class& bool_class = Class::Handle(object_store->bool_class()); |
| 2656 EXPECT_STREQ("Library:'dart:core' Class: bool", | 2656 EXPECT_STREQ("Library:'dart:core' Class: bool", |
| 2657 bool_class.ToCString()); | 2657 bool_class.ToCString()); |
| 2658 EXPECT_STREQ("true", Bool::True().ToCString()); | 2658 EXPECT_STREQ("true", Bool::True().ToCString()); |
| 2659 EXPECT_STREQ("false", Bool::False().ToCString()); | 2659 EXPECT_STREQ("false", Bool::False().ToCString()); |
| 2660 | 2660 |
| 2661 // Strings. | 2661 // Strings. |
| 2662 EXPECT_STREQ("Sugarbowl", | 2662 EXPECT_STREQ("Sugarbowl", |
| 2663 String::Handle(String::New("Sugarbowl")).ToCString()); | 2663 String::Handle(String::New("Sugarbowl")).ToCString()); |
| 2664 } | 2664 } |
| 2665 | 2665 |
| 2666 | 2666 |
| 2667 TEST_CASE(CheckedHandle) { | 2667 VM_TEST_CASE(CheckedHandle) { |
| 2668 // Ensure that null handles have the correct C++ vtable setup. | 2668 // Ensure that null handles have the correct C++ vtable setup. |
| 2669 const String& str1 = String::Handle(); | 2669 const String& str1 = String::Handle(); |
| 2670 EXPECT(str1.IsString()); | 2670 EXPECT(str1.IsString()); |
| 2671 EXPECT(str1.IsNull()); | 2671 EXPECT(str1.IsNull()); |
| 2672 const String& str2 = String::CheckedHandle(Object::null()); | 2672 const String& str2 = String::CheckedHandle(Object::null()); |
| 2673 EXPECT(str2.IsString()); | 2673 EXPECT(str2.IsString()); |
| 2674 EXPECT(str2.IsNull()); | 2674 EXPECT(str2.IsNull()); |
| 2675 String& str3 = String::Handle(); | 2675 String& str3 = String::Handle(); |
| 2676 str3 ^= Object::null(); | 2676 str3 ^= Object::null(); |
| 2677 EXPECT(str3.IsString()); | 2677 EXPECT(str3.IsString()); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 2695 const Library& owner_library = | 2695 const Library& owner_library = |
| 2696 Library::Handle(CreateDummyLibrary(lib_name)); | 2696 Library::Handle(CreateDummyLibrary(lib_name)); |
| 2697 owner_class.set_library(owner_library); | 2697 owner_class.set_library(owner_library); |
| 2698 const String& function_name = String::ZoneHandle(Symbols::New(name)); | 2698 const String& function_name = String::ZoneHandle(Symbols::New(name)); |
| 2699 return Function::New(function_name, RawFunction::kRegularFunction, | 2699 return Function::New(function_name, RawFunction::kRegularFunction, |
| 2700 true, false, false, false, false, owner_class, 0); | 2700 true, false, false, false, false, owner_class, 0); |
| 2701 } | 2701 } |
| 2702 | 2702 |
| 2703 | 2703 |
| 2704 // Test for Code and Instruction object creation. | 2704 // Test for Code and Instruction object creation. |
| 2705 TEST_CASE(Code) { | 2705 VM_TEST_CASE(Code) { |
| 2706 extern void GenerateIncrement(Assembler* assembler); | 2706 extern void GenerateIncrement(Assembler* assembler); |
| 2707 Assembler _assembler_; | 2707 Assembler _assembler_; |
| 2708 GenerateIncrement(&_assembler_); | 2708 GenerateIncrement(&_assembler_); |
| 2709 const Function& function = Function::Handle(CreateFunction("Test_Code")); | 2709 const Function& function = Function::Handle(CreateFunction("Test_Code")); |
| 2710 Code& code = Code::Handle(Code::FinalizeCode(function, &_assembler_)); | 2710 Code& code = Code::Handle(Code::FinalizeCode(function, &_assembler_)); |
| 2711 function.AttachCode(code); | 2711 function.AttachCode(code); |
| 2712 const Instructions& instructions = Instructions::Handle(code.instructions()); | 2712 const Instructions& instructions = Instructions::Handle(code.instructions()); |
| 2713 uword entry_point = instructions.EntryPoint(); | 2713 uword entry_point = instructions.EntryPoint(); |
| 2714 EXPECT_EQ(instructions.raw(), Instructions::FromEntryPoint(entry_point)); | 2714 EXPECT_EQ(instructions.raw(), Instructions::FromEntryPoint(entry_point)); |
| 2715 const Object& result = Object::Handle( | 2715 const Object& result = Object::Handle( |
| 2716 DartEntry::InvokeFunction(function, Array::empty_array())); | 2716 DartEntry::InvokeFunction(function, Array::empty_array())); |
| 2717 EXPECT_EQ(1, Smi::Cast(result).Value()); | 2717 EXPECT_EQ(1, Smi::Cast(result).Value()); |
| 2718 } | 2718 } |
| 2719 | 2719 |
| 2720 | 2720 |
| 2721 // Test for immutability of generated instructions. The test crashes with a | 2721 // Test for immutability of generated instructions. The test crashes with a |
| 2722 // segmentation fault when writing into it. | 2722 // segmentation fault when writing into it. |
| 2723 TEST_CASE(CodeImmutability) { | 2723 VM_TEST_CASE(CodeImmutability) { |
| 2724 extern void GenerateIncrement(Assembler* assembler); | 2724 extern void GenerateIncrement(Assembler* assembler); |
| 2725 Assembler _assembler_; | 2725 Assembler _assembler_; |
| 2726 GenerateIncrement(&_assembler_); | 2726 GenerateIncrement(&_assembler_); |
| 2727 const Function& function = Function::Handle(CreateFunction("Test_Code")); | 2727 const Function& function = Function::Handle(CreateFunction("Test_Code")); |
| 2728 Code& code = Code::Handle(Code::FinalizeCode(function, &_assembler_)); | 2728 Code& code = Code::Handle(Code::FinalizeCode(function, &_assembler_)); |
| 2729 function.AttachCode(code); | 2729 function.AttachCode(code); |
| 2730 Instructions& instructions = Instructions::Handle(code.instructions()); | 2730 Instructions& instructions = Instructions::Handle(code.instructions()); |
| 2731 uword entry_point = instructions.EntryPoint(); | 2731 uword entry_point = instructions.EntryPoint(); |
| 2732 EXPECT_EQ(instructions.raw(), Instructions::FromEntryPoint(entry_point)); | 2732 EXPECT_EQ(instructions.raw(), Instructions::FromEntryPoint(entry_point)); |
| 2733 // Try writing into the generated code, expected to crash. | 2733 // Try writing into the generated code, expected to crash. |
| 2734 *(reinterpret_cast<char*>(entry_point) + 1) = 1; | 2734 *(reinterpret_cast<char*>(entry_point) + 1) = 1; |
| 2735 if (!FLAG_write_protect_code) { | 2735 if (!FLAG_write_protect_code) { |
| 2736 // Since this test is expected to crash, crash if write protection of code | 2736 // Since this test is expected to crash, crash if write protection of code |
| 2737 // is switched off. | 2737 // is switched off. |
| 2738 // TODO(regis, fschneider): Should this be FATAL() instead? | 2738 // TODO(regis, fschneider): Should this be FATAL() instead? |
| 2739 OS::DebugBreak(); | 2739 OS::DebugBreak(); |
| 2740 } | 2740 } |
| 2741 } | 2741 } |
| 2742 | 2742 |
| 2743 | 2743 |
| 2744 // Test for Embedded String object in the instructions. | 2744 // Test for Embedded String object in the instructions. |
| 2745 TEST_CASE(EmbedStringInCode) { | 2745 VM_TEST_CASE(EmbedStringInCode) { |
| 2746 extern void GenerateEmbedStringInCode(Assembler* assembler, const char* str); | 2746 extern void GenerateEmbedStringInCode(Assembler* assembler, const char* str); |
| 2747 const char* kHello = "Hello World!"; | 2747 const char* kHello = "Hello World!"; |
| 2748 word expected_length = static_cast<word>(strlen(kHello)); | 2748 word expected_length = static_cast<word>(strlen(kHello)); |
| 2749 Assembler _assembler_; | 2749 Assembler _assembler_; |
| 2750 GenerateEmbedStringInCode(&_assembler_, kHello); | 2750 GenerateEmbedStringInCode(&_assembler_, kHello); |
| 2751 const Function& function = | 2751 const Function& function = |
| 2752 Function::Handle(CreateFunction("Test_EmbedStringInCode")); | 2752 Function::Handle(CreateFunction("Test_EmbedStringInCode")); |
| 2753 const Code& code = Code::Handle(Code::FinalizeCode(function, &_assembler_)); | 2753 const Code& code = Code::Handle(Code::FinalizeCode(function, &_assembler_)); |
| 2754 function.AttachCode(code); | 2754 function.AttachCode(code); |
| 2755 const Object& result = | 2755 const Object& result = |
| 2756 Object::Handle(DartEntry::InvokeFunction(function, Array::empty_array())); | 2756 Object::Handle(DartEntry::InvokeFunction(function, Array::empty_array())); |
| 2757 EXPECT(result.raw()->IsHeapObject()); | 2757 EXPECT(result.raw()->IsHeapObject()); |
| 2758 String& string_object = String::Handle(); | 2758 String& string_object = String::Handle(); |
| 2759 string_object ^= result.raw(); | 2759 string_object ^= result.raw(); |
| 2760 EXPECT(string_object.Length() == expected_length); | 2760 EXPECT(string_object.Length() == expected_length); |
| 2761 for (int i = 0; i < expected_length; i ++) { | 2761 for (int i = 0; i < expected_length; i ++) { |
| 2762 EXPECT(string_object.CharAt(i) == kHello[i]); | 2762 EXPECT(string_object.CharAt(i) == kHello[i]); |
| 2763 } | 2763 } |
| 2764 } | 2764 } |
| 2765 | 2765 |
| 2766 | 2766 |
| 2767 // Test for Embedded Smi object in the instructions. | 2767 // Test for Embedded Smi object in the instructions. |
| 2768 TEST_CASE(EmbedSmiInCode) { | 2768 VM_TEST_CASE(EmbedSmiInCode) { |
| 2769 extern void GenerateEmbedSmiInCode(Assembler* assembler, intptr_t value); | 2769 extern void GenerateEmbedSmiInCode(Assembler* assembler, intptr_t value); |
| 2770 const intptr_t kSmiTestValue = 5; | 2770 const intptr_t kSmiTestValue = 5; |
| 2771 Assembler _assembler_; | 2771 Assembler _assembler_; |
| 2772 GenerateEmbedSmiInCode(&_assembler_, kSmiTestValue); | 2772 GenerateEmbedSmiInCode(&_assembler_, kSmiTestValue); |
| 2773 const Function& function = | 2773 const Function& function = |
| 2774 Function::Handle(CreateFunction("Test_EmbedSmiInCode")); | 2774 Function::Handle(CreateFunction("Test_EmbedSmiInCode")); |
| 2775 const Code& code = Code::Handle(Code::FinalizeCode(function, &_assembler_)); | 2775 const Code& code = Code::Handle(Code::FinalizeCode(function, &_assembler_)); |
| 2776 function.AttachCode(code); | 2776 function.AttachCode(code); |
| 2777 const Object& result = | 2777 const Object& result = |
| 2778 Object::Handle(DartEntry::InvokeFunction(function, Array::empty_array())); | 2778 Object::Handle(DartEntry::InvokeFunction(function, Array::empty_array())); |
| 2779 EXPECT(Smi::Cast(result).Value() == kSmiTestValue); | 2779 EXPECT(Smi::Cast(result).Value() == kSmiTestValue); |
| 2780 } | 2780 } |
| 2781 | 2781 |
| 2782 | 2782 |
| 2783 #if defined(ARCH_IS_64_BIT) | 2783 #if defined(ARCH_IS_64_BIT) |
| 2784 // Test for Embedded Smi object in the instructions. | 2784 // Test for Embedded Smi object in the instructions. |
| 2785 TEST_CASE(EmbedSmiIn64BitCode) { | 2785 VM_TEST_CASE(EmbedSmiIn64BitCode) { |
| 2786 extern void GenerateEmbedSmiInCode(Assembler* assembler, intptr_t value); | 2786 extern void GenerateEmbedSmiInCode(Assembler* assembler, intptr_t value); |
| 2787 const intptr_t kSmiTestValue = DART_INT64_C(5) << 32; | 2787 const intptr_t kSmiTestValue = DART_INT64_C(5) << 32; |
| 2788 Assembler _assembler_; | 2788 Assembler _assembler_; |
| 2789 GenerateEmbedSmiInCode(&_assembler_, kSmiTestValue); | 2789 GenerateEmbedSmiInCode(&_assembler_, kSmiTestValue); |
| 2790 const Function& function = | 2790 const Function& function = |
| 2791 Function::Handle(CreateFunction("Test_EmbedSmiIn64BitCode")); | 2791 Function::Handle(CreateFunction("Test_EmbedSmiIn64BitCode")); |
| 2792 const Code& code = Code::Handle(Code::FinalizeCode(function, &_assembler_)); | 2792 const Code& code = Code::Handle(Code::FinalizeCode(function, &_assembler_)); |
| 2793 function.AttachCode(code); | 2793 function.AttachCode(code); |
| 2794 const Object& result = | 2794 const Object& result = |
| 2795 Object::Handle(DartEntry::InvokeFunction(function, Array::empty_array())); | 2795 Object::Handle(DartEntry::InvokeFunction(function, Array::empty_array())); |
| 2796 EXPECT(Smi::Cast(result).Value() == kSmiTestValue); | 2796 EXPECT(Smi::Cast(result).Value() == kSmiTestValue); |
| 2797 } | 2797 } |
| 2798 #endif // ARCH_IS_64_BIT | 2798 #endif // ARCH_IS_64_BIT |
| 2799 | 2799 |
| 2800 | 2800 |
| 2801 TEST_CASE(ExceptionHandlers) { | 2801 VM_TEST_CASE(ExceptionHandlers) { |
| 2802 const int kNumEntries = 4; | 2802 const int kNumEntries = 4; |
| 2803 // Add an exception handler table to the code. | 2803 // Add an exception handler table to the code. |
| 2804 ExceptionHandlers& exception_handlers = ExceptionHandlers::Handle(); | 2804 ExceptionHandlers& exception_handlers = ExceptionHandlers::Handle(); |
| 2805 exception_handlers ^= ExceptionHandlers::New(kNumEntries); | 2805 exception_handlers ^= ExceptionHandlers::New(kNumEntries); |
| 2806 const bool kNeedsStacktrace = true; | 2806 const bool kNeedsStacktrace = true; |
| 2807 const bool kNoStacktrace = false; | 2807 const bool kNoStacktrace = false; |
| 2808 exception_handlers.SetHandlerInfo(0, -1, 20u, kNeedsStacktrace, false); | 2808 exception_handlers.SetHandlerInfo(0, -1, 20u, kNeedsStacktrace, false); |
| 2809 exception_handlers.SetHandlerInfo(1, 0, 30u, kNeedsStacktrace, false); | 2809 exception_handlers.SetHandlerInfo(1, 0, 30u, kNeedsStacktrace, false); |
| 2810 exception_handlers.SetHandlerInfo(2, -1, 40u, kNoStacktrace, true); | 2810 exception_handlers.SetHandlerInfo(2, -1, 40u, kNoStacktrace, true); |
| 2811 exception_handlers.SetHandlerInfo(3, 1, 150u, kNoStacktrace, true); | 2811 exception_handlers.SetHandlerInfo(3, 1, 150u, kNoStacktrace, true); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 2829 EXPECT(handlers.NeedsStacktrace(0)); | 2829 EXPECT(handlers.NeedsStacktrace(0)); |
| 2830 EXPECT(!handlers.HasCatchAll(0)); | 2830 EXPECT(!handlers.HasCatchAll(0)); |
| 2831 EXPECT_EQ(20u, info.handler_pc_offset); | 2831 EXPECT_EQ(20u, info.handler_pc_offset); |
| 2832 EXPECT_EQ(1, handlers.OuterTryIndex(3)); | 2832 EXPECT_EQ(1, handlers.OuterTryIndex(3)); |
| 2833 EXPECT_EQ(150u, handlers.HandlerPCOffset(3)); | 2833 EXPECT_EQ(150u, handlers.HandlerPCOffset(3)); |
| 2834 EXPECT(!handlers.NeedsStacktrace(3)); | 2834 EXPECT(!handlers.NeedsStacktrace(3)); |
| 2835 EXPECT(handlers.HasCatchAll(3)); | 2835 EXPECT(handlers.HasCatchAll(3)); |
| 2836 } | 2836 } |
| 2837 | 2837 |
| 2838 | 2838 |
| 2839 TEST_CASE(PcDescriptors) { | 2839 VM_TEST_CASE(PcDescriptors) { |
| 2840 DescriptorList* builder = new DescriptorList(0); | 2840 DescriptorList* builder = new DescriptorList(0); |
| 2841 | 2841 |
| 2842 // kind, pc_offset, deopt_id, token_pos, try_index | 2842 // kind, pc_offset, deopt_id, token_pos, try_index |
| 2843 builder->AddDescriptor(RawPcDescriptors::kOther, 10, 1, 20, 1); | 2843 builder->AddDescriptor(RawPcDescriptors::kOther, 10, 1, 20, 1); |
| 2844 builder->AddDescriptor(RawPcDescriptors::kDeopt, 20, 2, 30, 0); | 2844 builder->AddDescriptor(RawPcDescriptors::kDeopt, 20, 2, 30, 0); |
| 2845 builder->AddDescriptor(RawPcDescriptors::kOther, 30, 3, 40, 1); | 2845 builder->AddDescriptor(RawPcDescriptors::kOther, 30, 3, 40, 1); |
| 2846 builder->AddDescriptor(RawPcDescriptors::kOther, 10, 4, 40, 2); | 2846 builder->AddDescriptor(RawPcDescriptors::kOther, 10, 4, 40, 2); |
| 2847 builder->AddDescriptor(RawPcDescriptors::kOther, 10, 5, 80, 3); | 2847 builder->AddDescriptor(RawPcDescriptors::kOther, 10, 5, 80, 3); |
| 2848 builder->AddDescriptor(RawPcDescriptors::kOther, 80, 6, 150, 3); | 2848 builder->AddDescriptor(RawPcDescriptors::kOther, 80, 6, 150, 3); |
| 2849 | 2849 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2886 | 2886 |
| 2887 EXPECT_EQ(3, iter.TryIndex()); | 2887 EXPECT_EQ(3, iter.TryIndex()); |
| 2888 EXPECT_EQ(static_cast<uword>(80), iter.PcOffset()); | 2888 EXPECT_EQ(static_cast<uword>(80), iter.PcOffset()); |
| 2889 EXPECT_EQ(150, iter.TokenPos()); | 2889 EXPECT_EQ(150, iter.TokenPos()); |
| 2890 EXPECT_EQ(RawPcDescriptors::kOther, iter.Kind()); | 2890 EXPECT_EQ(RawPcDescriptors::kOther, iter.Kind()); |
| 2891 | 2891 |
| 2892 EXPECT_EQ(false, iter.MoveNext()); | 2892 EXPECT_EQ(false, iter.MoveNext()); |
| 2893 } | 2893 } |
| 2894 | 2894 |
| 2895 | 2895 |
| 2896 TEST_CASE(PcDescriptorsLargeDeltas) { | 2896 VM_TEST_CASE(PcDescriptorsLargeDeltas) { |
| 2897 DescriptorList* builder = new DescriptorList(0); | 2897 DescriptorList* builder = new DescriptorList(0); |
| 2898 | 2898 |
| 2899 // kind, pc_offset, deopt_id, token_pos, try_index | 2899 // kind, pc_offset, deopt_id, token_pos, try_index |
| 2900 builder->AddDescriptor(RawPcDescriptors::kOther, 100, 1, 200, 1); | 2900 builder->AddDescriptor(RawPcDescriptors::kOther, 100, 1, 200, 1); |
| 2901 builder->AddDescriptor(RawPcDescriptors::kDeopt, 200, 2, 300, 0); | 2901 builder->AddDescriptor(RawPcDescriptors::kDeopt, 200, 2, 300, 0); |
| 2902 builder->AddDescriptor(RawPcDescriptors::kOther, 300, 3, 400, 1); | 2902 builder->AddDescriptor(RawPcDescriptors::kOther, 300, 3, 400, 1); |
| 2903 builder->AddDescriptor(RawPcDescriptors::kOther, 100, 4, 0, 2); | 2903 builder->AddDescriptor(RawPcDescriptors::kOther, 100, 4, 0, 2); |
| 2904 builder->AddDescriptor(RawPcDescriptors::kOther, 100, 5, 800, 3); | 2904 builder->AddDescriptor(RawPcDescriptors::kOther, 100, 5, 800, 3); |
| 2905 builder->AddDescriptor(RawPcDescriptors::kOther, 800, 6, 150, 3); | 2905 builder->AddDescriptor(RawPcDescriptors::kOther, 800, 6, 150, 3); |
| 2906 | 2906 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2961 static RawField* CreateTestField(const char* name) { | 2961 static RawField* CreateTestField(const char* name) { |
| 2962 const Class& cls = Class::Handle(CreateTestClass("global:")); | 2962 const Class& cls = Class::Handle(CreateTestClass("global:")); |
| 2963 const String& field_name = String::Handle(Symbols::New(name)); | 2963 const String& field_name = String::Handle(Symbols::New(name)); |
| 2964 const Field& field = | 2964 const Field& field = |
| 2965 Field::Handle(Field::New(field_name, true, false, false, true, cls, | 2965 Field::Handle(Field::New(field_name, true, false, false, true, cls, |
| 2966 Object::dynamic_type(), 0)); | 2966 Object::dynamic_type(), 0)); |
| 2967 return field.raw(); | 2967 return field.raw(); |
| 2968 } | 2968 } |
| 2969 | 2969 |
| 2970 | 2970 |
| 2971 TEST_CASE(ClassDictionaryIterator) { | 2971 VM_TEST_CASE(ClassDictionaryIterator) { |
| 2972 Class& ae66 = Class::ZoneHandle(CreateTestClass("Ae6/6")); | 2972 Class& ae66 = Class::ZoneHandle(CreateTestClass("Ae6/6")); |
| 2973 Class& re44 = Class::ZoneHandle(CreateTestClass("Re4/4")); | 2973 Class& re44 = Class::ZoneHandle(CreateTestClass("Re4/4")); |
| 2974 Field& ce68 = Field::ZoneHandle(CreateTestField("Ce6/8")); | 2974 Field& ce68 = Field::ZoneHandle(CreateTestField("Ce6/8")); |
| 2975 Field& tee = Field::ZoneHandle(CreateTestField("TEE")); | 2975 Field& tee = Field::ZoneHandle(CreateTestField("TEE")); |
| 2976 String& url = String::ZoneHandle(String::New("SBB")); | 2976 String& url = String::ZoneHandle(String::New("SBB")); |
| 2977 Library& lib = Library::Handle(Library::New(url)); | 2977 Library& lib = Library::Handle(Library::New(url)); |
| 2978 lib.AddClass(ae66); | 2978 lib.AddClass(ae66); |
| 2979 lib.AddObject(ce68, String::ZoneHandle(ce68.name())); | 2979 lib.AddObject(ce68, String::ZoneHandle(ce68.name())); |
| 2980 lib.AddClass(re44); | 2980 lib.AddClass(re44); |
| 2981 lib.AddObject(tee, String::ZoneHandle(tee.name())); | 2981 lib.AddObject(tee, String::ZoneHandle(tee.name())); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 3005 is_static, | 3005 is_static, |
| 3006 is_const, | 3006 is_const, |
| 3007 is_abstract, | 3007 is_abstract, |
| 3008 is_external, | 3008 is_external, |
| 3009 is_native, | 3009 is_native, |
| 3010 cls, | 3010 cls, |
| 3011 0); | 3011 0); |
| 3012 } | 3012 } |
| 3013 | 3013 |
| 3014 | 3014 |
| 3015 TEST_CASE(ICData) { | 3015 VM_TEST_CASE(ICData) { |
| 3016 Function& function = Function::Handle(GetDummyTarget("Bern")); | 3016 Function& function = Function::Handle(GetDummyTarget("Bern")); |
| 3017 const intptr_t id = 12; | 3017 const intptr_t id = 12; |
| 3018 const intptr_t num_args_tested = 1; | 3018 const intptr_t num_args_tested = 1; |
| 3019 const String& target_name = String::Handle(Symbols::New("Thun")); | 3019 const String& target_name = String::Handle(Symbols::New("Thun")); |
| 3020 const Array& args_descriptor = | 3020 const Array& args_descriptor = |
| 3021 Array::Handle(ArgumentsDescriptor::New(1, Object::null_array())); | 3021 Array::Handle(ArgumentsDescriptor::New(1, Object::null_array())); |
| 3022 ICData& o1 = ICData::Handle(); | 3022 ICData& o1 = ICData::Handle(); |
| 3023 o1 = ICData::New(function, target_name, args_descriptor, id, num_args_tested); | 3023 o1 = ICData::New(function, target_name, args_descriptor, id, num_args_tested); |
| 3024 EXPECT_EQ(1, o1.NumArgsTested()); | 3024 EXPECT_EQ(1, o1.NumArgsTested()); |
| 3025 EXPECT_EQ(id, o1.deopt_id()); | 3025 EXPECT_EQ(id, o1.deopt_id()); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3077 | 3077 |
| 3078 // Check ICData for unoptimized static calls. | 3078 // Check ICData for unoptimized static calls. |
| 3079 const intptr_t kNumArgsChecked = 0; | 3079 const intptr_t kNumArgsChecked = 0; |
| 3080 const ICData& scall_icdata = ICData::Handle( | 3080 const ICData& scall_icdata = ICData::Handle( |
| 3081 ICData::New(function, target_name, args_descriptor, 57, kNumArgsChecked)); | 3081 ICData::New(function, target_name, args_descriptor, 57, kNumArgsChecked)); |
| 3082 scall_icdata.AddTarget(target1); | 3082 scall_icdata.AddTarget(target1); |
| 3083 EXPECT_EQ(target1.raw(), scall_icdata.GetTargetAt(0)); | 3083 EXPECT_EQ(target1.raw(), scall_icdata.GetTargetAt(0)); |
| 3084 } | 3084 } |
| 3085 | 3085 |
| 3086 | 3086 |
| 3087 TEST_CASE(SubtypeTestCache) { | 3087 VM_TEST_CASE(SubtypeTestCache) { |
| 3088 String& class_name = String::Handle(Symbols::New("EmptyClass")); | 3088 String& class_name = String::Handle(Symbols::New("EmptyClass")); |
| 3089 Script& script = Script::Handle(); | 3089 Script& script = Script::Handle(); |
| 3090 const Class& empty_class = | 3090 const Class& empty_class = |
| 3091 Class::Handle(CreateDummyClass(class_name, script)); | 3091 Class::Handle(CreateDummyClass(class_name, script)); |
| 3092 SubtypeTestCache& cache = SubtypeTestCache::Handle(SubtypeTestCache::New()); | 3092 SubtypeTestCache& cache = SubtypeTestCache::Handle(SubtypeTestCache::New()); |
| 3093 EXPECT(!cache.IsNull()); | 3093 EXPECT(!cache.IsNull()); |
| 3094 EXPECT_EQ(0, cache.NumberOfChecks()); | 3094 EXPECT_EQ(0, cache.NumberOfChecks()); |
| 3095 const TypeArguments& targ_0 = TypeArguments::Handle(TypeArguments::New(2)); | 3095 const TypeArguments& targ_0 = TypeArguments::Handle(TypeArguments::New(2)); |
| 3096 const TypeArguments& targ_1 = TypeArguments::Handle(TypeArguments::New(3)); | 3096 const TypeArguments& targ_1 = TypeArguments::Handle(TypeArguments::New(3)); |
| 3097 cache.AddCheck(empty_class.id(), targ_0, targ_1, Bool::True()); | 3097 cache.AddCheck(empty_class.id(), targ_0, targ_1, Bool::True()); |
| 3098 EXPECT_EQ(1, cache.NumberOfChecks()); | 3098 EXPECT_EQ(1, cache.NumberOfChecks()); |
| 3099 intptr_t test_class_id = -1; | 3099 intptr_t test_class_id = -1; |
| 3100 TypeArguments& test_targ_0 = TypeArguments::Handle(); | 3100 TypeArguments& test_targ_0 = TypeArguments::Handle(); |
| 3101 TypeArguments& test_targ_1 = TypeArguments::Handle(); | 3101 TypeArguments& test_targ_1 = TypeArguments::Handle(); |
| 3102 Bool& test_result = Bool::Handle(); | 3102 Bool& test_result = Bool::Handle(); |
| 3103 cache.GetCheck(0, &test_class_id, &test_targ_0, &test_targ_1, &test_result); | 3103 cache.GetCheck(0, &test_class_id, &test_targ_0, &test_targ_1, &test_result); |
| 3104 EXPECT_EQ(empty_class.id(), test_class_id); | 3104 EXPECT_EQ(empty_class.id(), test_class_id); |
| 3105 EXPECT_EQ(targ_0.raw(), test_targ_0.raw()); | 3105 EXPECT_EQ(targ_0.raw(), test_targ_0.raw()); |
| 3106 EXPECT_EQ(targ_1.raw(), test_targ_1.raw()); | 3106 EXPECT_EQ(targ_1.raw(), test_targ_1.raw()); |
| 3107 EXPECT_EQ(Bool::True().raw(), test_result.raw()); | 3107 EXPECT_EQ(Bool::True().raw(), test_result.raw()); |
| 3108 } | 3108 } |
| 3109 | 3109 |
| 3110 | 3110 |
| 3111 TEST_CASE(FieldTests) { | 3111 VM_TEST_CASE(FieldTests) { |
| 3112 const String& f = String::Handle(String::New("oneField")); | 3112 const String& f = String::Handle(String::New("oneField")); |
| 3113 const String& getter_f = String::Handle(Field::GetterName(f)); | 3113 const String& getter_f = String::Handle(Field::GetterName(f)); |
| 3114 const String& setter_f = String::Handle(Field::SetterName(f)); | 3114 const String& setter_f = String::Handle(Field::SetterName(f)); |
| 3115 EXPECT(!Field::IsGetterName(f)); | 3115 EXPECT(!Field::IsGetterName(f)); |
| 3116 EXPECT(!Field::IsSetterName(f)); | 3116 EXPECT(!Field::IsSetterName(f)); |
| 3117 EXPECT(Field::IsGetterName(getter_f)); | 3117 EXPECT(Field::IsGetterName(getter_f)); |
| 3118 EXPECT(!Field::IsSetterName(getter_f)); | 3118 EXPECT(!Field::IsSetterName(getter_f)); |
| 3119 EXPECT(!Field::IsGetterName(setter_f)); | 3119 EXPECT(!Field::IsGetterName(setter_f)); |
| 3120 EXPECT(Field::IsSetterName(setter_f)); | 3120 EXPECT(Field::IsSetterName(setter_f)); |
| 3121 EXPECT_STREQ(f.ToCString(), | 3121 EXPECT_STREQ(f.ToCString(), |
| 3122 String::Handle(Field::NameFromGetter(getter_f)).ToCString()); | 3122 String::Handle(Field::NameFromGetter(getter_f)).ToCString()); |
| 3123 EXPECT_STREQ(f.ToCString(), | 3123 EXPECT_STREQ(f.ToCString(), |
| 3124 String::Handle(Field::NameFromSetter(setter_f)).ToCString()); | 3124 String::Handle(Field::NameFromSetter(setter_f)).ToCString()); |
| 3125 } | 3125 } |
| 3126 | 3126 |
| 3127 | 3127 |
| 3128 | 3128 |
| 3129 | 3129 |
| 3130 // Expose helper function from object.cc for testing. | 3130 // Expose helper function from object.cc for testing. |
| 3131 bool EqualsIgnoringPrivate(const String& name, const String& private_name); | 3131 bool EqualsIgnoringPrivate(const String& name, const String& private_name); |
| 3132 | 3132 |
| 3133 | 3133 |
| 3134 TEST_CASE(EqualsIgnoringPrivate) { | 3134 VM_TEST_CASE(EqualsIgnoringPrivate) { |
| 3135 String& mangled_name = String::Handle(); | 3135 String& mangled_name = String::Handle(); |
| 3136 String& bare_name = String::Handle(); | 3136 String& bare_name = String::Handle(); |
| 3137 | 3137 |
| 3138 // Simple matches. | 3138 // Simple matches. |
| 3139 mangled_name = OneByteString::New("foo"); | 3139 mangled_name = OneByteString::New("foo"); |
| 3140 bare_name = OneByteString::New("foo"); | 3140 bare_name = OneByteString::New("foo"); |
| 3141 EXPECT(String::EqualsIgnoringPrivateKey(mangled_name, bare_name)); | 3141 EXPECT(String::EqualsIgnoringPrivateKey(mangled_name, bare_name)); |
| 3142 | 3142 |
| 3143 mangled_name = OneByteString::New("foo."); | 3143 mangled_name = OneByteString::New("foo."); |
| 3144 bare_name = OneByteString::New("foo."); | 3144 bare_name = OneByteString::New("foo."); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3257 // str1 - ExternalOneByteString, str2 - OneByteString. | 3257 // str1 - ExternalOneByteString, str2 - OneByteString. |
| 3258 EXPECT(String::EqualsIgnoringPrivateKey(ext_mangled_name, bare_name)); | 3258 EXPECT(String::EqualsIgnoringPrivateKey(ext_mangled_name, bare_name)); |
| 3259 | 3259 |
| 3260 // str1 - ExternalOneByteString, str2 - ExternalOneByteString. | 3260 // str1 - ExternalOneByteString, str2 - ExternalOneByteString. |
| 3261 EXPECT(String::EqualsIgnoringPrivateKey(ext_mangled_name, ext_bare_name)); | 3261 EXPECT(String::EqualsIgnoringPrivateKey(ext_mangled_name, ext_bare_name)); |
| 3262 EXPECT(!String::EqualsIgnoringPrivateKey(ext_mangled_name, | 3262 EXPECT(!String::EqualsIgnoringPrivateKey(ext_mangled_name, |
| 3263 ext_bad_bare_name)); | 3263 ext_bad_bare_name)); |
| 3264 } | 3264 } |
| 3265 | 3265 |
| 3266 | 3266 |
| 3267 TEST_CASE(ArrayNew_Overflow_Crash) { | 3267 VM_TEST_CASE(ArrayNew_Overflow_Crash) { |
| 3268 Array::Handle(Array::New(Array::kMaxElements + 1)); | 3268 Array::Handle(Array::New(Array::kMaxElements + 1)); |
| 3269 } | 3269 } |
| 3270 | 3270 |
| 3271 | 3271 |
| 3272 TEST_CASE(StackTraceFormat) { | 3272 TEST_CASE(StackTraceFormat) { |
| 3273 const char* kScriptChars = | 3273 const char* kScriptChars = |
| 3274 "void baz() {\n" | 3274 "void baz() {\n" |
| 3275 " throw 'MyException';\n" | 3275 " throw 'MyException';\n" |
| 3276 "}\n" | 3276 "}\n" |
| 3277 "\n" | 3277 "\n" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3323 "#4 MyClass.field (test-lib:25:5)\n" | 3323 "#4 MyClass.field (test-lib:25:5)\n" |
| 3324 "#5 MyClass.foo.fooHelper (test-lib:30:7)\n" | 3324 "#5 MyClass.foo.fooHelper (test-lib:30:7)\n" |
| 3325 "#6 MyClass.foo (test-lib:32:14)\n" | 3325 "#6 MyClass.foo (test-lib:32:14)\n" |
| 3326 "#7 MyClass.MyClass.<anonymous closure> (test-lib:21:12)\n" | 3326 "#7 MyClass.MyClass.<anonymous closure> (test-lib:21:12)\n" |
| 3327 "#8 MyClass.MyClass (test-lib:21:18)\n" | 3327 "#8 MyClass.MyClass (test-lib:21:18)\n" |
| 3328 "#9 main.<anonymous closure> (test-lib:37:14)\n" | 3328 "#9 main.<anonymous closure> (test-lib:37:14)\n" |
| 3329 "#10 main (test-lib:37:24)"); | 3329 "#10 main (test-lib:37:24)"); |
| 3330 } | 3330 } |
| 3331 | 3331 |
| 3332 | 3332 |
| 3333 TEST_CASE(WeakProperty_PreserveCrossGen) { | 3333 VM_TEST_CASE(WeakProperty_PreserveCrossGen) { |
| 3334 Isolate* isolate = Isolate::Current(); | 3334 Isolate* isolate = Isolate::Current(); |
| 3335 WeakProperty& weak = WeakProperty::Handle(); | 3335 WeakProperty& weak = WeakProperty::Handle(); |
| 3336 { | 3336 { |
| 3337 // Weak property and value in new. Key in old. | 3337 // Weak property and value in new. Key in old. |
| 3338 HANDLESCOPE(thread); | 3338 HANDLESCOPE(thread); |
| 3339 String& key = String::Handle(); | 3339 String& key = String::Handle(); |
| 3340 key ^= OneByteString::New("key", Heap::kOld); | 3340 key ^= OneByteString::New("key", Heap::kOld); |
| 3341 String& value = String::Handle(); | 3341 String& value = String::Handle(); |
| 3342 value ^= OneByteString::New("value", Heap::kNew); | 3342 value ^= OneByteString::New("value", Heap::kNew); |
| 3343 weak ^= WeakProperty::New(Heap::kNew); | 3343 weak ^= WeakProperty::New(Heap::kNew); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3435 value ^= OneByteString::null(); | 3435 value ^= OneByteString::null(); |
| 3436 } | 3436 } |
| 3437 isolate->heap()->CollectAllGarbage(); | 3437 isolate->heap()->CollectAllGarbage(); |
| 3438 // Weak property key and value should survive due to cross-generation | 3438 // Weak property key and value should survive due to cross-generation |
| 3439 // pointers. | 3439 // pointers. |
| 3440 EXPECT(weak.key() != Object::null()); | 3440 EXPECT(weak.key() != Object::null()); |
| 3441 EXPECT(weak.value() != Object::null()); | 3441 EXPECT(weak.value() != Object::null()); |
| 3442 } | 3442 } |
| 3443 | 3443 |
| 3444 | 3444 |
| 3445 TEST_CASE(WeakProperty_PreserveRecurse) { | 3445 VM_TEST_CASE(WeakProperty_PreserveRecurse) { |
| 3446 // This used to end in an infinite recursion. Caused by scavenging the weak | 3446 // This used to end in an infinite recursion. Caused by scavenging the weak |
| 3447 // property before scavenging the key. | 3447 // property before scavenging the key. |
| 3448 Isolate* isolate = Isolate::Current(); | 3448 Isolate* isolate = Isolate::Current(); |
| 3449 WeakProperty& weak = WeakProperty::Handle(); | 3449 WeakProperty& weak = WeakProperty::Handle(); |
| 3450 Array& arr = Array::Handle(Array::New(1)); | 3450 Array& arr = Array::Handle(Array::New(1)); |
| 3451 { | 3451 { |
| 3452 HANDLESCOPE(thread); | 3452 HANDLESCOPE(thread); |
| 3453 String& key = String::Handle(); | 3453 String& key = String::Handle(); |
| 3454 key ^= OneByteString::New("key"); | 3454 key ^= OneByteString::New("key"); |
| 3455 arr.SetAt(0, key); | 3455 arr.SetAt(0, key); |
| 3456 String& value = String::Handle(); | 3456 String& value = String::Handle(); |
| 3457 value ^= OneByteString::New("value"); | 3457 value ^= OneByteString::New("value"); |
| 3458 weak ^= WeakProperty::New(); | 3458 weak ^= WeakProperty::New(); |
| 3459 weak.set_key(key); | 3459 weak.set_key(key); |
| 3460 weak.set_value(value); | 3460 weak.set_value(value); |
| 3461 } | 3461 } |
| 3462 isolate->heap()->CollectAllGarbage(); | 3462 isolate->heap()->CollectAllGarbage(); |
| 3463 EXPECT(weak.key() != Object::null()); | 3463 EXPECT(weak.key() != Object::null()); |
| 3464 EXPECT(weak.value() != Object::null()); | 3464 EXPECT(weak.value() != Object::null()); |
| 3465 } | 3465 } |
| 3466 | 3466 |
| 3467 | 3467 |
| 3468 TEST_CASE(WeakProperty_PreserveOne_NewSpace) { | 3468 VM_TEST_CASE(WeakProperty_PreserveOne_NewSpace) { |
| 3469 Isolate* isolate = Isolate::Current(); | 3469 Isolate* isolate = Isolate::Current(); |
| 3470 WeakProperty& weak = WeakProperty::Handle(); | 3470 WeakProperty& weak = WeakProperty::Handle(); |
| 3471 String& key = String::Handle(); | 3471 String& key = String::Handle(); |
| 3472 key ^= OneByteString::New("key"); | 3472 key ^= OneByteString::New("key"); |
| 3473 { | 3473 { |
| 3474 HANDLESCOPE(thread); | 3474 HANDLESCOPE(thread); |
| 3475 String& value = String::Handle(); | 3475 String& value = String::Handle(); |
| 3476 value ^= OneByteString::New("value"); | 3476 value ^= OneByteString::New("value"); |
| 3477 weak ^= WeakProperty::New(); | 3477 weak ^= WeakProperty::New(); |
| 3478 weak.set_key(key); | 3478 weak.set_key(key); |
| 3479 weak.set_value(value); | 3479 weak.set_value(value); |
| 3480 } | 3480 } |
| 3481 isolate->heap()->CollectAllGarbage(); | 3481 isolate->heap()->CollectAllGarbage(); |
| 3482 EXPECT(weak.key() != Object::null()); | 3482 EXPECT(weak.key() != Object::null()); |
| 3483 EXPECT(weak.value() != Object::null()); | 3483 EXPECT(weak.value() != Object::null()); |
| 3484 } | 3484 } |
| 3485 | 3485 |
| 3486 | 3486 |
| 3487 TEST_CASE(WeakProperty_PreserveTwo_NewSpace) { | 3487 VM_TEST_CASE(WeakProperty_PreserveTwo_NewSpace) { |
| 3488 Isolate* isolate = Isolate::Current(); | 3488 Isolate* isolate = Isolate::Current(); |
| 3489 WeakProperty& weak1 = WeakProperty::Handle(); | 3489 WeakProperty& weak1 = WeakProperty::Handle(); |
| 3490 String& key1 = String::Handle(); | 3490 String& key1 = String::Handle(); |
| 3491 key1 ^= OneByteString::New("key1"); | 3491 key1 ^= OneByteString::New("key1"); |
| 3492 WeakProperty& weak2 = WeakProperty::Handle(); | 3492 WeakProperty& weak2 = WeakProperty::Handle(); |
| 3493 String& key2 = String::Handle(); | 3493 String& key2 = String::Handle(); |
| 3494 key2 ^= OneByteString::New("key2"); | 3494 key2 ^= OneByteString::New("key2"); |
| 3495 { | 3495 { |
| 3496 HANDLESCOPE(thread); | 3496 HANDLESCOPE(thread); |
| 3497 String& value1 = String::Handle(); | 3497 String& value1 = String::Handle(); |
| 3498 value1 ^= OneByteString::New("value1"); | 3498 value1 ^= OneByteString::New("value1"); |
| 3499 weak1 ^= WeakProperty::New(); | 3499 weak1 ^= WeakProperty::New(); |
| 3500 weak1.set_key(key1); | 3500 weak1.set_key(key1); |
| 3501 weak1.set_value(value1); | 3501 weak1.set_value(value1); |
| 3502 String& value2 = String::Handle(); | 3502 String& value2 = String::Handle(); |
| 3503 value2 ^= OneByteString::New("value2"); | 3503 value2 ^= OneByteString::New("value2"); |
| 3504 weak2 ^= WeakProperty::New(); | 3504 weak2 ^= WeakProperty::New(); |
| 3505 weak2.set_key(key2); | 3505 weak2.set_key(key2); |
| 3506 weak2.set_value(value2); | 3506 weak2.set_value(value2); |
| 3507 } | 3507 } |
| 3508 isolate->heap()->CollectAllGarbage(); | 3508 isolate->heap()->CollectAllGarbage(); |
| 3509 EXPECT(weak1.key() != Object::null()); | 3509 EXPECT(weak1.key() != Object::null()); |
| 3510 EXPECT(weak1.value() != Object::null()); | 3510 EXPECT(weak1.value() != Object::null()); |
| 3511 EXPECT(weak2.key() != Object::null()); | 3511 EXPECT(weak2.key() != Object::null()); |
| 3512 EXPECT(weak2.value() != Object::null()); | 3512 EXPECT(weak2.value() != Object::null()); |
| 3513 } | 3513 } |
| 3514 | 3514 |
| 3515 | 3515 |
| 3516 TEST_CASE(WeakProperty_PreserveTwoShared_NewSpace) { | 3516 VM_TEST_CASE(WeakProperty_PreserveTwoShared_NewSpace) { |
| 3517 Isolate* isolate = Isolate::Current(); | 3517 Isolate* isolate = Isolate::Current(); |
| 3518 WeakProperty& weak1 = WeakProperty::Handle(); | 3518 WeakProperty& weak1 = WeakProperty::Handle(); |
| 3519 WeakProperty& weak2 = WeakProperty::Handle(); | 3519 WeakProperty& weak2 = WeakProperty::Handle(); |
| 3520 String& key = String::Handle(); | 3520 String& key = String::Handle(); |
| 3521 key ^= OneByteString::New("key"); | 3521 key ^= OneByteString::New("key"); |
| 3522 { | 3522 { |
| 3523 HANDLESCOPE(thread); | 3523 HANDLESCOPE(thread); |
| 3524 String& value1 = String::Handle(); | 3524 String& value1 = String::Handle(); |
| 3525 value1 ^= OneByteString::New("value1"); | 3525 value1 ^= OneByteString::New("value1"); |
| 3526 weak1 ^= WeakProperty::New(); | 3526 weak1 ^= WeakProperty::New(); |
| 3527 weak1.set_key(key); | 3527 weak1.set_key(key); |
| 3528 weak1.set_value(value1); | 3528 weak1.set_value(value1); |
| 3529 String& value2 = String::Handle(); | 3529 String& value2 = String::Handle(); |
| 3530 value2 ^= OneByteString::New("value2"); | 3530 value2 ^= OneByteString::New("value2"); |
| 3531 weak2 ^= WeakProperty::New(); | 3531 weak2 ^= WeakProperty::New(); |
| 3532 weak2.set_key(key); | 3532 weak2.set_key(key); |
| 3533 weak2.set_value(value2); | 3533 weak2.set_value(value2); |
| 3534 } | 3534 } |
| 3535 isolate->heap()->CollectAllGarbage(); | 3535 isolate->heap()->CollectAllGarbage(); |
| 3536 EXPECT(weak1.key() != Object::null()); | 3536 EXPECT(weak1.key() != Object::null()); |
| 3537 EXPECT(weak1.value() != Object::null()); | 3537 EXPECT(weak1.value() != Object::null()); |
| 3538 EXPECT(weak2.key() != Object::null()); | 3538 EXPECT(weak2.key() != Object::null()); |
| 3539 EXPECT(weak2.value() != Object::null()); | 3539 EXPECT(weak2.value() != Object::null()); |
| 3540 } | 3540 } |
| 3541 | 3541 |
| 3542 | 3542 |
| 3543 TEST_CASE(WeakProperty_PreserveOne_OldSpace) { | 3543 VM_TEST_CASE(WeakProperty_PreserveOne_OldSpace) { |
| 3544 Isolate* isolate = Isolate::Current(); | 3544 Isolate* isolate = Isolate::Current(); |
| 3545 WeakProperty& weak = WeakProperty::Handle(); | 3545 WeakProperty& weak = WeakProperty::Handle(); |
| 3546 String& key = String::Handle(); | 3546 String& key = String::Handle(); |
| 3547 key ^= OneByteString::New("key", Heap::kOld); | 3547 key ^= OneByteString::New("key", Heap::kOld); |
| 3548 { | 3548 { |
| 3549 HANDLESCOPE(thread); | 3549 HANDLESCOPE(thread); |
| 3550 String& value = String::Handle(); | 3550 String& value = String::Handle(); |
| 3551 value ^= OneByteString::New("value", Heap::kOld); | 3551 value ^= OneByteString::New("value", Heap::kOld); |
| 3552 weak ^= WeakProperty::New(Heap::kOld); | 3552 weak ^= WeakProperty::New(Heap::kOld); |
| 3553 weak.set_key(key); | 3553 weak.set_key(key); |
| 3554 weak.set_value(value); | 3554 weak.set_value(value); |
| 3555 } | 3555 } |
| 3556 isolate->heap()->CollectAllGarbage(); | 3556 isolate->heap()->CollectAllGarbage(); |
| 3557 EXPECT(weak.key() != Object::null()); | 3557 EXPECT(weak.key() != Object::null()); |
| 3558 EXPECT(weak.value() != Object::null()); | 3558 EXPECT(weak.value() != Object::null()); |
| 3559 } | 3559 } |
| 3560 | 3560 |
| 3561 | 3561 |
| 3562 TEST_CASE(WeakProperty_PreserveTwo_OldSpace) { | 3562 VM_TEST_CASE(WeakProperty_PreserveTwo_OldSpace) { |
| 3563 Isolate* isolate = Isolate::Current(); | 3563 Isolate* isolate = Isolate::Current(); |
| 3564 WeakProperty& weak1 = WeakProperty::Handle(); | 3564 WeakProperty& weak1 = WeakProperty::Handle(); |
| 3565 String& key1 = String::Handle(); | 3565 String& key1 = String::Handle(); |
| 3566 key1 ^= OneByteString::New("key1", Heap::kOld); | 3566 key1 ^= OneByteString::New("key1", Heap::kOld); |
| 3567 WeakProperty& weak2 = WeakProperty::Handle(); | 3567 WeakProperty& weak2 = WeakProperty::Handle(); |
| 3568 String& key2 = String::Handle(); | 3568 String& key2 = String::Handle(); |
| 3569 key2 ^= OneByteString::New("key2", Heap::kOld); | 3569 key2 ^= OneByteString::New("key2", Heap::kOld); |
| 3570 { | 3570 { |
| 3571 HANDLESCOPE(thread); | 3571 HANDLESCOPE(thread); |
| 3572 String& value1 = String::Handle(); | 3572 String& value1 = String::Handle(); |
| 3573 value1 ^= OneByteString::New("value1", Heap::kOld); | 3573 value1 ^= OneByteString::New("value1", Heap::kOld); |
| 3574 weak1 ^= WeakProperty::New(Heap::kOld); | 3574 weak1 ^= WeakProperty::New(Heap::kOld); |
| 3575 weak1.set_key(key1); | 3575 weak1.set_key(key1); |
| 3576 weak1.set_value(value1); | 3576 weak1.set_value(value1); |
| 3577 String& value2 = String::Handle(); | 3577 String& value2 = String::Handle(); |
| 3578 value2 ^= OneByteString::New("value2", Heap::kOld); | 3578 value2 ^= OneByteString::New("value2", Heap::kOld); |
| 3579 weak2 ^= WeakProperty::New(Heap::kOld); | 3579 weak2 ^= WeakProperty::New(Heap::kOld); |
| 3580 weak2.set_key(key2); | 3580 weak2.set_key(key2); |
| 3581 weak2.set_value(value2); | 3581 weak2.set_value(value2); |
| 3582 } | 3582 } |
| 3583 isolate->heap()->CollectAllGarbage(); | 3583 isolate->heap()->CollectAllGarbage(); |
| 3584 EXPECT(weak1.key() != Object::null()); | 3584 EXPECT(weak1.key() != Object::null()); |
| 3585 EXPECT(weak1.value() != Object::null()); | 3585 EXPECT(weak1.value() != Object::null()); |
| 3586 EXPECT(weak2.key() != Object::null()); | 3586 EXPECT(weak2.key() != Object::null()); |
| 3587 EXPECT(weak2.value() != Object::null()); | 3587 EXPECT(weak2.value() != Object::null()); |
| 3588 } | 3588 } |
| 3589 | 3589 |
| 3590 | 3590 |
| 3591 TEST_CASE(WeakProperty_PreserveTwoShared_OldSpace) { | 3591 VM_TEST_CASE(WeakProperty_PreserveTwoShared_OldSpace) { |
| 3592 Isolate* isolate = Isolate::Current(); | 3592 Isolate* isolate = Isolate::Current(); |
| 3593 WeakProperty& weak1 = WeakProperty::Handle(); | 3593 WeakProperty& weak1 = WeakProperty::Handle(); |
| 3594 WeakProperty& weak2 = WeakProperty::Handle(); | 3594 WeakProperty& weak2 = WeakProperty::Handle(); |
| 3595 String& key = String::Handle(); | 3595 String& key = String::Handle(); |
| 3596 key ^= OneByteString::New("key", Heap::kOld); | 3596 key ^= OneByteString::New("key", Heap::kOld); |
| 3597 { | 3597 { |
| 3598 HANDLESCOPE(thread); | 3598 HANDLESCOPE(thread); |
| 3599 String& value1 = String::Handle(); | 3599 String& value1 = String::Handle(); |
| 3600 value1 ^= OneByteString::New("value1", Heap::kOld); | 3600 value1 ^= OneByteString::New("value1", Heap::kOld); |
| 3601 weak1 ^= WeakProperty::New(Heap::kOld); | 3601 weak1 ^= WeakProperty::New(Heap::kOld); |
| 3602 weak1.set_key(key); | 3602 weak1.set_key(key); |
| 3603 weak1.set_value(value1); | 3603 weak1.set_value(value1); |
| 3604 String& value2 = String::Handle(); | 3604 String& value2 = String::Handle(); |
| 3605 value2 ^= OneByteString::New("value2", Heap::kOld); | 3605 value2 ^= OneByteString::New("value2", Heap::kOld); |
| 3606 weak2 ^= WeakProperty::New(Heap::kOld); | 3606 weak2 ^= WeakProperty::New(Heap::kOld); |
| 3607 weak2.set_key(key); | 3607 weak2.set_key(key); |
| 3608 weak2.set_value(value2); | 3608 weak2.set_value(value2); |
| 3609 } | 3609 } |
| 3610 isolate->heap()->CollectAllGarbage(); | 3610 isolate->heap()->CollectAllGarbage(); |
| 3611 EXPECT(weak1.key() != Object::null()); | 3611 EXPECT(weak1.key() != Object::null()); |
| 3612 EXPECT(weak1.value() != Object::null()); | 3612 EXPECT(weak1.value() != Object::null()); |
| 3613 EXPECT(weak2.key() != Object::null()); | 3613 EXPECT(weak2.key() != Object::null()); |
| 3614 EXPECT(weak2.value() != Object::null()); | 3614 EXPECT(weak2.value() != Object::null()); |
| 3615 } | 3615 } |
| 3616 | 3616 |
| 3617 | 3617 |
| 3618 TEST_CASE(WeakProperty_ClearOne_NewSpace) { | 3618 VM_TEST_CASE(WeakProperty_ClearOne_NewSpace) { |
| 3619 Isolate* isolate = Isolate::Current(); | 3619 Isolate* isolate = Isolate::Current(); |
| 3620 WeakProperty& weak = WeakProperty::Handle(); | 3620 WeakProperty& weak = WeakProperty::Handle(); |
| 3621 { | 3621 { |
| 3622 HANDLESCOPE(thread); | 3622 HANDLESCOPE(thread); |
| 3623 String& key = String::Handle(); | 3623 String& key = String::Handle(); |
| 3624 key ^= OneByteString::New("key"); | 3624 key ^= OneByteString::New("key"); |
| 3625 String& value = String::Handle(); | 3625 String& value = String::Handle(); |
| 3626 value ^= OneByteString::New("value"); | 3626 value ^= OneByteString::New("value"); |
| 3627 weak ^= WeakProperty::New(); | 3627 weak ^= WeakProperty::New(); |
| 3628 weak.set_key(key); | 3628 weak.set_key(key); |
| 3629 weak.set_value(value); | 3629 weak.set_value(value); |
| 3630 key ^= OneByteString::null(); | 3630 key ^= OneByteString::null(); |
| 3631 value ^= OneByteString::null(); | 3631 value ^= OneByteString::null(); |
| 3632 } | 3632 } |
| 3633 isolate->heap()->CollectAllGarbage(); | 3633 isolate->heap()->CollectAllGarbage(); |
| 3634 EXPECT(weak.key() == Object::null()); | 3634 EXPECT(weak.key() == Object::null()); |
| 3635 EXPECT(weak.value() == Object::null()); | 3635 EXPECT(weak.value() == Object::null()); |
| 3636 } | 3636 } |
| 3637 | 3637 |
| 3638 | 3638 |
| 3639 TEST_CASE(WeakProperty_ClearTwoShared_NewSpace) { | 3639 VM_TEST_CASE(WeakProperty_ClearTwoShared_NewSpace) { |
| 3640 Isolate* isolate = Isolate::Current(); | 3640 Isolate* isolate = Isolate::Current(); |
| 3641 WeakProperty& weak1 = WeakProperty::Handle(); | 3641 WeakProperty& weak1 = WeakProperty::Handle(); |
| 3642 WeakProperty& weak2 = WeakProperty::Handle(); | 3642 WeakProperty& weak2 = WeakProperty::Handle(); |
| 3643 { | 3643 { |
| 3644 HANDLESCOPE(thread); | 3644 HANDLESCOPE(thread); |
| 3645 String& key = String::Handle(); | 3645 String& key = String::Handle(); |
| 3646 key ^= OneByteString::New("key"); | 3646 key ^= OneByteString::New("key"); |
| 3647 String& value1 = String::Handle(); | 3647 String& value1 = String::Handle(); |
| 3648 value1 ^= OneByteString::New("value1"); | 3648 value1 ^= OneByteString::New("value1"); |
| 3649 weak1 ^= WeakProperty::New(); | 3649 weak1 ^= WeakProperty::New(); |
| 3650 weak1.set_key(key); | 3650 weak1.set_key(key); |
| 3651 weak1.set_value(value1); | 3651 weak1.set_value(value1); |
| 3652 String& value2 = String::Handle(); | 3652 String& value2 = String::Handle(); |
| 3653 value2 ^= OneByteString::New("value2"); | 3653 value2 ^= OneByteString::New("value2"); |
| 3654 weak2 ^= WeakProperty::New(); | 3654 weak2 ^= WeakProperty::New(); |
| 3655 weak2.set_key(key); | 3655 weak2.set_key(key); |
| 3656 weak2.set_value(value2); | 3656 weak2.set_value(value2); |
| 3657 } | 3657 } |
| 3658 isolate->heap()->CollectAllGarbage(); | 3658 isolate->heap()->CollectAllGarbage(); |
| 3659 EXPECT(weak1.key() == Object::null()); | 3659 EXPECT(weak1.key() == Object::null()); |
| 3660 EXPECT(weak1.value() == Object::null()); | 3660 EXPECT(weak1.value() == Object::null()); |
| 3661 EXPECT(weak2.key() == Object::null()); | 3661 EXPECT(weak2.key() == Object::null()); |
| 3662 EXPECT(weak2.value() == Object::null()); | 3662 EXPECT(weak2.value() == Object::null()); |
| 3663 } | 3663 } |
| 3664 | 3664 |
| 3665 | 3665 |
| 3666 TEST_CASE(WeakProperty_ClearOne_OldSpace) { | 3666 VM_TEST_CASE(WeakProperty_ClearOne_OldSpace) { |
| 3667 Isolate* isolate = Isolate::Current(); | 3667 Isolate* isolate = Isolate::Current(); |
| 3668 WeakProperty& weak = WeakProperty::Handle(); | 3668 WeakProperty& weak = WeakProperty::Handle(); |
| 3669 { | 3669 { |
| 3670 HANDLESCOPE(thread); | 3670 HANDLESCOPE(thread); |
| 3671 String& key = String::Handle(); | 3671 String& key = String::Handle(); |
| 3672 key ^= OneByteString::New("key", Heap::kOld); | 3672 key ^= OneByteString::New("key", Heap::kOld); |
| 3673 String& value = String::Handle(); | 3673 String& value = String::Handle(); |
| 3674 value ^= OneByteString::New("value", Heap::kOld); | 3674 value ^= OneByteString::New("value", Heap::kOld); |
| 3675 weak ^= WeakProperty::New(Heap::kOld); | 3675 weak ^= WeakProperty::New(Heap::kOld); |
| 3676 weak.set_key(key); | 3676 weak.set_key(key); |
| 3677 weak.set_value(value); | 3677 weak.set_value(value); |
| 3678 key ^= OneByteString::null(); | 3678 key ^= OneByteString::null(); |
| 3679 value ^= OneByteString::null(); | 3679 value ^= OneByteString::null(); |
| 3680 } | 3680 } |
| 3681 isolate->heap()->CollectAllGarbage(); | 3681 isolate->heap()->CollectAllGarbage(); |
| 3682 EXPECT(weak.key() == Object::null()); | 3682 EXPECT(weak.key() == Object::null()); |
| 3683 EXPECT(weak.value() == Object::null()); | 3683 EXPECT(weak.value() == Object::null()); |
| 3684 } | 3684 } |
| 3685 | 3685 |
| 3686 | 3686 |
| 3687 TEST_CASE(WeakProperty_ClearTwoShared_OldSpace) { | 3687 VM_TEST_CASE(WeakProperty_ClearTwoShared_OldSpace) { |
| 3688 Isolate* isolate = Isolate::Current(); | 3688 Isolate* isolate = Isolate::Current(); |
| 3689 WeakProperty& weak1 = WeakProperty::Handle(); | 3689 WeakProperty& weak1 = WeakProperty::Handle(); |
| 3690 WeakProperty& weak2 = WeakProperty::Handle(); | 3690 WeakProperty& weak2 = WeakProperty::Handle(); |
| 3691 { | 3691 { |
| 3692 HANDLESCOPE(thread); | 3692 HANDLESCOPE(thread); |
| 3693 String& key = String::Handle(); | 3693 String& key = String::Handle(); |
| 3694 key ^= OneByteString::New("key", Heap::kOld); | 3694 key ^= OneByteString::New("key", Heap::kOld); |
| 3695 String& value1 = String::Handle(); | 3695 String& value1 = String::Handle(); |
| 3696 value1 ^= OneByteString::New("value1"); | 3696 value1 ^= OneByteString::New("value1"); |
| 3697 weak1 ^= WeakProperty::New(Heap::kOld); | 3697 weak1 ^= WeakProperty::New(Heap::kOld); |
| 3698 weak1.set_key(key); | 3698 weak1.set_key(key); |
| 3699 weak1.set_value(value1); | 3699 weak1.set_value(value1); |
| 3700 String& value2 = String::Handle(); | 3700 String& value2 = String::Handle(); |
| 3701 value2 ^= OneByteString::New("value2", Heap::kOld); | 3701 value2 ^= OneByteString::New("value2", Heap::kOld); |
| 3702 weak2 ^= WeakProperty::New(Heap::kOld); | 3702 weak2 ^= WeakProperty::New(Heap::kOld); |
| 3703 weak2.set_key(key); | 3703 weak2.set_key(key); |
| 3704 weak2.set_value(value2); | 3704 weak2.set_value(value2); |
| 3705 } | 3705 } |
| 3706 isolate->heap()->CollectAllGarbage(); | 3706 isolate->heap()->CollectAllGarbage(); |
| 3707 EXPECT(weak1.key() == Object::null()); | 3707 EXPECT(weak1.key() == Object::null()); |
| 3708 EXPECT(weak1.value() == Object::null()); | 3708 EXPECT(weak1.value() == Object::null()); |
| 3709 EXPECT(weak2.key() == Object::null()); | 3709 EXPECT(weak2.key() == Object::null()); |
| 3710 EXPECT(weak2.value() == Object::null()); | 3710 EXPECT(weak2.value() == Object::null()); |
| 3711 } | 3711 } |
| 3712 | 3712 |
| 3713 | 3713 |
| 3714 TEST_CASE(MirrorReference) { | 3714 VM_TEST_CASE(MirrorReference) { |
| 3715 const MirrorReference& reference = | 3715 const MirrorReference& reference = |
| 3716 MirrorReference::Handle(MirrorReference::New(Object::Handle())); | 3716 MirrorReference::Handle(MirrorReference::New(Object::Handle())); |
| 3717 Object& initial_referent = Object::Handle(reference.referent()); | 3717 Object& initial_referent = Object::Handle(reference.referent()); |
| 3718 EXPECT(initial_referent.IsNull()); | 3718 EXPECT(initial_referent.IsNull()); |
| 3719 | 3719 |
| 3720 Library& library = Library::Handle(Library::CoreLibrary()); | 3720 Library& library = Library::Handle(Library::CoreLibrary()); |
| 3721 EXPECT(!library.IsNull()); | 3721 EXPECT(!library.IsNull()); |
| 3722 EXPECT(library.IsLibrary()); | 3722 EXPECT(library.IsLibrary()); |
| 3723 reference.set_referent(library); | 3723 reference.set_referent(library); |
| 3724 const Object& returned_referent = Object::Handle(reference.referent()); | 3724 const Object& returned_referent = Object::Handle(reference.referent()); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3762 | 3762 |
| 3763 | 3763 |
| 3764 static RawClass* GetClass(const Library& lib, const char* name) { | 3764 static RawClass* GetClass(const Library& lib, const char* name) { |
| 3765 const Class& cls = Class::Handle( | 3765 const Class& cls = Class::Handle( |
| 3766 lib.LookupClass(String::Handle(Symbols::New(name)))); | 3766 lib.LookupClass(String::Handle(Symbols::New(name)))); |
| 3767 EXPECT(!cls.IsNull()); // No ambiguity error expected. | 3767 EXPECT(!cls.IsNull()); // No ambiguity error expected. |
| 3768 return cls.raw(); | 3768 return cls.raw(); |
| 3769 } | 3769 } |
| 3770 | 3770 |
| 3771 | 3771 |
| 3772 TEST_CASE(FindClosureIndex) { | 3772 VM_TEST_CASE(FindClosureIndex) { |
| 3773 // Allocate the class first. | 3773 // Allocate the class first. |
| 3774 const String& class_name = String::Handle(Symbols::New("MyClass")); | 3774 const String& class_name = String::Handle(Symbols::New("MyClass")); |
| 3775 const Script& script = Script::Handle(); | 3775 const Script& script = Script::Handle(); |
| 3776 const Class& cls = Class::Handle(CreateDummyClass(class_name, script)); | 3776 const Class& cls = Class::Handle(CreateDummyClass(class_name, script)); |
| 3777 const Array& functions = Array::Handle(Array::New(1)); | 3777 const Array& functions = Array::Handle(Array::New(1)); |
| 3778 const Isolate* iso = Isolate::Current(); | 3778 const Isolate* iso = Isolate::Current(); |
| 3779 | 3779 |
| 3780 Function& parent = Function::Handle(); | 3780 Function& parent = Function::Handle(); |
| 3781 const String& parent_name = String::Handle(Symbols::New("foo_papa")); | 3781 const String& parent_name = String::Handle(Symbols::New("foo_papa")); |
| 3782 parent = Function::New(parent_name, RawFunction::kRegularFunction, | 3782 parent = Function::New(parent_name, RawFunction::kRegularFunction, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 3798 EXPECT_EQ(bad_closure_index, -1); | 3798 EXPECT_EQ(bad_closure_index, -1); |
| 3799 | 3799 |
| 3800 // Retrieve closure function via index. | 3800 // Retrieve closure function via index. |
| 3801 Function& func_from_index = Function::Handle(); | 3801 Function& func_from_index = Function::Handle(); |
| 3802 func_from_index ^= iso->ClosureFunctionFromIndex(good_closure_index); | 3802 func_from_index ^= iso->ClosureFunctionFromIndex(good_closure_index); |
| 3803 // Same closure function. | 3803 // Same closure function. |
| 3804 EXPECT_EQ(func_from_index.raw(), function.raw()); | 3804 EXPECT_EQ(func_from_index.raw(), function.raw()); |
| 3805 } | 3805 } |
| 3806 | 3806 |
| 3807 | 3807 |
| 3808 TEST_CASE(FindInvocationDispatcherFunctionIndex) { | 3808 VM_TEST_CASE(FindInvocationDispatcherFunctionIndex) { |
| 3809 const String& class_name = String::Handle(Symbols::New("MyClass")); | 3809 const String& class_name = String::Handle(Symbols::New("MyClass")); |
| 3810 const Script& script = Script::Handle(); | 3810 const Script& script = Script::Handle(); |
| 3811 const Class& cls = Class::Handle(CreateDummyClass(class_name, script)); | 3811 const Class& cls = Class::Handle(CreateDummyClass(class_name, script)); |
| 3812 ClassFinalizer::FinalizeTypesInClass(cls); | 3812 ClassFinalizer::FinalizeTypesInClass(cls); |
| 3813 | 3813 |
| 3814 const Array& functions = Array::Handle(Array::New(1)); | 3814 const Array& functions = Array::Handle(Array::New(1)); |
| 3815 Function& parent = Function::Handle(); | 3815 Function& parent = Function::Handle(); |
| 3816 const String& parent_name = String::Handle(Symbols::New("foo_papa")); | 3816 const String& parent_name = String::Handle(Symbols::New("foo_papa")); |
| 3817 parent = Function::New(parent_name, RawFunction::kRegularFunction, | 3817 parent = Function::New(parent_name, RawFunction::kRegularFunction, |
| 3818 false, false, false, false, false, cls, 0); | 3818 false, false, false, false, false, cls, 0); |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4049 | 4049 |
| 4050 // After setting a breakpoint in a function A.b, it is no longer inlineable. | 4050 // After setting a breakpoint in a function A.b, it is no longer inlineable. |
| 4051 Breakpoint* bpt = | 4051 Breakpoint* bpt = |
| 4052 Isolate::Current()->debugger()->SetBreakpointAtLine(name, | 4052 Isolate::Current()->debugger()->SetBreakpointAtLine(name, |
| 4053 kBreakpointLine); | 4053 kBreakpointLine); |
| 4054 ASSERT(bpt != NULL); | 4054 ASSERT(bpt != NULL); |
| 4055 EXPECT(!func_b.CanBeInlined()); | 4055 EXPECT(!func_b.CanBeInlined()); |
| 4056 } | 4056 } |
| 4057 | 4057 |
| 4058 | 4058 |
| 4059 TEST_CASE(SpecialClassesHaveEmptyArrays) { | 4059 VM_TEST_CASE(SpecialClassesHaveEmptyArrays) { |
| 4060 ObjectStore* object_store = Isolate::Current()->object_store(); | 4060 ObjectStore* object_store = Isolate::Current()->object_store(); |
| 4061 Class& cls = Class::Handle(); | 4061 Class& cls = Class::Handle(); |
| 4062 Object& array = Object::Handle(); | 4062 Object& array = Object::Handle(); |
| 4063 | 4063 |
| 4064 cls = object_store->null_class(); | 4064 cls = object_store->null_class(); |
| 4065 array = cls.fields(); | 4065 array = cls.fields(); |
| 4066 EXPECT(!array.IsNull()); | 4066 EXPECT(!array.IsNull()); |
| 4067 EXPECT(array.IsArray()); | 4067 EXPECT(array.IsArray()); |
| 4068 array = cls.functions(); | 4068 array = cls.functions(); |
| 4069 EXPECT(!array.IsNull()); | 4069 EXPECT(!array.IsNull()); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4104 handle.IsLiteralToken()) { | 4104 handle.IsLiteralToken()) { |
| 4105 return; | 4105 return; |
| 4106 } | 4106 } |
| 4107 objects_->Add(&handle); | 4107 objects_->Add(&handle); |
| 4108 } | 4108 } |
| 4109 private: | 4109 private: |
| 4110 GrowableArray<Object*>* objects_; | 4110 GrowableArray<Object*>* objects_; |
| 4111 }; | 4111 }; |
| 4112 | 4112 |
| 4113 | 4113 |
| 4114 TEST_CASE(PrintJSON) { | 4114 VM_TEST_CASE(PrintJSON) { |
| 4115 Heap* heap = Isolate::Current()->heap(); | 4115 Heap* heap = Isolate::Current()->heap(); |
| 4116 heap->CollectAllGarbage(); | 4116 heap->CollectAllGarbage(); |
| 4117 GrowableArray<Object*> objects; | 4117 GrowableArray<Object*> objects; |
| 4118 ObjectAccumulator acc(&objects); | 4118 ObjectAccumulator acc(&objects); |
| 4119 heap->IterateObjects(&acc); | 4119 heap->IterateObjects(&acc); |
| 4120 for (intptr_t i = 0; i < objects.length(); ++i) { | 4120 for (intptr_t i = 0; i < objects.length(); ++i) { |
| 4121 JSONStream js; | 4121 JSONStream js; |
| 4122 objects[i]->PrintJSON(&js, false); | 4122 objects[i]->PrintJSON(&js, false); |
| 4123 EXPECT_SUBSTRING("\"type\":", js.ToCString()); | 4123 EXPECT_SUBSTRING("\"type\":", js.ToCString()); |
| 4124 } | 4124 } |
| 4125 } | 4125 } |
| 4126 | 4126 |
| 4127 | 4127 |
| 4128 TEST_CASE(PrintJSONPrimitives) { | 4128 VM_TEST_CASE(PrintJSONPrimitives) { |
| 4129 char buffer[1024]; | 4129 char buffer[1024]; |
| 4130 Isolate* isolate = Isolate::Current(); | 4130 Isolate* isolate = Isolate::Current(); |
| 4131 | 4131 |
| 4132 // Class reference | 4132 // Class reference |
| 4133 { | 4133 { |
| 4134 JSONStream js; | 4134 JSONStream js; |
| 4135 Class& cls = Class::Handle(isolate->object_store()->bool_class()); | 4135 Class& cls = Class::Handle(isolate->object_store()->bool_class()); |
| 4136 cls.PrintJSON(&js, true); | 4136 cls.PrintJSON(&js, true); |
| 4137 ElideJSONSubstring("classes", js.ToCString(), buffer); | 4137 ElideJSONSubstring("classes", js.ToCString(), buffer); |
| 4138 EXPECT_STREQ( | 4138 EXPECT_STREQ( |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4583 for (int i = 0; i < n; i++) { | 4583 for (int i = 0; i < n; i++) { |
| 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 = String::Handle(zone, Symbols::FromConcatAll(pieces)); | 4587 const String& res1 = String::Handle(zone, Symbols::FromConcatAll(pieces)); |
| 4588 const String& res2 = String::Handle(zone, String::ConcatAll(array)); | 4588 const String& res2 = String::Handle(zone, String::ConcatAll(array)); |
| 4589 EXPECT(res1.Equals(res2)); | 4589 EXPECT(res1.Equals(res2)); |
| 4590 } | 4590 } |
| 4591 | 4591 |
| 4592 | 4592 |
| 4593 TEST_CASE(Symbols_FromConcatAll) { | 4593 VM_TEST_CASE(Symbols_FromConcatAll) { |
| 4594 { | 4594 { |
| 4595 const String* data[3] = { &Symbols::FallThroughError(), | 4595 const String* data[3] = { &Symbols::FallThroughError(), |
| 4596 &Symbols::Dot(), | 4596 &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, '!' }; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4655 } | 4655 } |
| 4656 } | 4656 } |
| 4657 | 4657 |
| 4658 | 4658 |
| 4659 struct TestResult { | 4659 struct TestResult { |
| 4660 const char* in; | 4660 const char* in; |
| 4661 const char* out; | 4661 const char* out; |
| 4662 }; | 4662 }; |
| 4663 | 4663 |
| 4664 | 4664 |
| 4665 TEST_CASE(String_IdentifierPrettyName) { | 4665 VM_TEST_CASE(String_IdentifierPrettyName) { |
| 4666 TestResult tests[] = { | 4666 TestResult tests[] = { |
| 4667 {"(dynamic, dynamic) => void", "(dynamic, dynamic) => void"}, | 4667 {"(dynamic, dynamic) => void", "(dynamic, dynamic) => void"}, |
| 4668 {"_List@915557746", "_List"}, | 4668 {"_List@915557746", "_List"}, |
| 4669 {"_HashMap@600006304<K, V>(dynamic) => V", "_HashMap<K, V>(dynamic) => V"}, | 4669 {"_HashMap@600006304<K, V>(dynamic) => V", "_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::IdentifierPrettyName(test); | 4685 result = String::IdentifierPrettyName(test); |
| 4686 EXPECT_STREQ(tests[i].out, result.ToCString()); | 4686 EXPECT_STREQ(tests[i].out, result.ToCString()); |
| 4687 } | 4687 } |
| 4688 } | 4688 } |
| 4689 | 4689 |
| 4690 } // namespace dart | 4690 } // namespace dart |
| OLD | NEW |