OLD | NEW |
1 // Copyright 2007-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2009 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 i::Heap::CollectGarbage(0, i::NEW_SPACE); // in survivor space now | 565 i::Heap::CollectGarbage(0, i::NEW_SPACE); // in survivor space now |
566 i::Heap::CollectGarbage(0, i::NEW_SPACE); // in old gen now | 566 i::Heap::CollectGarbage(0, i::NEW_SPACE); // in old gen now |
567 i::Handle<i::String> isymbol = i::Factory::SymbolFromString(istring); | 567 i::Handle<i::String> isymbol = i::Factory::SymbolFromString(istring); |
568 CHECK(isymbol->IsSymbol()); | 568 CHECK(isymbol->IsSymbol()); |
569 } | 569 } |
570 i::Heap::CollectAllGarbage(false); | 570 i::Heap::CollectAllGarbage(false); |
571 i::Heap::CollectAllGarbage(false); | 571 i::Heap::CollectAllGarbage(false); |
572 } | 572 } |
573 | 573 |
574 | 574 |
| 575 THREADED_TEST(StringConcat) { |
| 576 { |
| 577 v8::HandleScope scope; |
| 578 LocalContext env; |
| 579 const char* one_byte_string_1 = "function a_times_t"; |
| 580 const char* two_byte_string_1 = "wo_plus_b(a, b) {return "; |
| 581 const char* one_byte_extern_1 = "a * 2 + b;} a_times_two_plus_b(4, 8) + "; |
| 582 const char* two_byte_extern_1 = "a_times_two_plus_b(4, 8) + "; |
| 583 const char* one_byte_string_2 = "a_times_two_plus_b(4, 8) + "; |
| 584 const char* two_byte_string_2 = "a_times_two_plus_b(4, 8) + "; |
| 585 const char* two_byte_extern_2 = "a_times_two_plus_b(1, 2);"; |
| 586 Local<String> left = v8_str(one_byte_string_1); |
| 587 Local<String> right = String::New(AsciiToTwoByteString(two_byte_string_1)); |
| 588 Local<String> source = String::Concat(left, right); |
| 589 right = String::NewExternal( |
| 590 new TestAsciiResource(i::StrDup(one_byte_extern_1))); |
| 591 source = String::Concat(source, right); |
| 592 right = String::NewExternal( |
| 593 new TestResource(AsciiToTwoByteString(two_byte_extern_1))); |
| 594 source = String::Concat(source, right); |
| 595 right = v8_str(one_byte_string_2); |
| 596 source = String::Concat(source, right); |
| 597 right = String::New(AsciiToTwoByteString(two_byte_string_2)); |
| 598 source = String::Concat(source, right); |
| 599 right = String::NewExternal( |
| 600 new TestResource(AsciiToTwoByteString(two_byte_extern_2))); |
| 601 source = String::Concat(source, right); |
| 602 Local<Script> script = Script::Compile(source); |
| 603 Local<Value> value = script->Run(); |
| 604 CHECK(value->IsNumber()); |
| 605 CHECK_EQ(68, value->Int32Value()); |
| 606 } |
| 607 v8::internal::CompilationCache::Clear(); |
| 608 i::Heap::CollectAllGarbage(false); |
| 609 i::Heap::CollectAllGarbage(false); |
| 610 } |
| 611 |
| 612 |
575 THREADED_TEST(GlobalProperties) { | 613 THREADED_TEST(GlobalProperties) { |
576 v8::HandleScope scope; | 614 v8::HandleScope scope; |
577 LocalContext env; | 615 LocalContext env; |
578 v8::Handle<v8::Object> global = env->Global(); | 616 v8::Handle<v8::Object> global = env->Global(); |
579 global->Set(v8_str("pi"), v8_num(3.1415926)); | 617 global->Set(v8_str("pi"), v8_num(3.1415926)); |
580 Local<Value> pi = global->Get(v8_str("pi")); | 618 Local<Value> pi = global->Get(v8_str("pi")); |
581 CHECK_EQ(3.1415926, pi->NumberValue()); | 619 CHECK_EQ(3.1415926, pi->NumberValue()); |
582 } | 620 } |
583 | 621 |
584 | 622 |
(...skipping 7485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8070 env->Global()->Set(v8_str("get_stack_limit"), fun); | 8108 env->Global()->Set(v8_str("get_stack_limit"), fun); |
8071 CompileRun("get_stack_limit();"); | 8109 CompileRun("get_stack_limit();"); |
8072 | 8110 |
8073 CHECK(stack_limit == set_limit); | 8111 CHECK(stack_limit == set_limit); |
8074 } | 8112 } |
8075 { | 8113 { |
8076 v8::Locker locker; | 8114 v8::Locker locker; |
8077 CHECK(stack_limit == set_limit); | 8115 CHECK(stack_limit == set_limit); |
8078 } | 8116 } |
8079 } | 8117 } |
OLD | NEW |