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

Side by Side Diff: test/cctest/test-api.cc

Issue 2959007: Fix preparsing from a source string that is not external.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/scanner.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 8594 matching lines...) Expand 10 before | Expand all | Expand 10 after
8605 } 8605 }
8606 8606
8607 8607
8608 // Verifies that the Handle<String> and const char* versions of the API produce 8608 // Verifies that the Handle<String> and const char* versions of the API produce
8609 // the same results (at least for one trivial case). 8609 // the same results (at least for one trivial case).
8610 TEST(PreCompileAPIVariationsAreSame) { 8610 TEST(PreCompileAPIVariationsAreSame) {
8611 v8::V8::Initialize(); 8611 v8::V8::Initialize();
8612 v8::HandleScope scope; 8612 v8::HandleScope scope;
8613 8613
8614 const char* cstring = "function foo(a) { return a+1; }"; 8614 const char* cstring = "function foo(a) { return a+1; }";
8615
8615 v8::ScriptData* sd_from_cstring = 8616 v8::ScriptData* sd_from_cstring =
8616 v8::ScriptData::PreCompile(cstring, i::StrLength(cstring)); 8617 v8::ScriptData::PreCompile(cstring, i::StrLength(cstring));
8617 8618
8618 TestAsciiResource* resource = new TestAsciiResource(cstring); 8619 TestAsciiResource* resource = new TestAsciiResource(cstring);
8619 v8::ScriptData* sd_from_istring = v8::ScriptData::PreCompile( 8620 v8::ScriptData* sd_from_external_string = v8::ScriptData::PreCompile(
8620 v8::String::NewExternal(resource)); 8621 v8::String::NewExternal(resource));
8621 8622
8622 CHECK_EQ(sd_from_cstring->Length(), sd_from_istring->Length()); 8623 v8::ScriptData* sd_from_string = v8::ScriptData::PreCompile(
8624 v8::String::New(cstring));
8625
8626 CHECK_EQ(sd_from_cstring->Length(), sd_from_external_string->Length());
8623 CHECK_EQ(0, memcmp(sd_from_cstring->Data(), 8627 CHECK_EQ(0, memcmp(sd_from_cstring->Data(),
8624 sd_from_istring->Data(), 8628 sd_from_external_string->Data(),
8625 sd_from_cstring->Length())); 8629 sd_from_cstring->Length()));
8626 8630
8631 CHECK_EQ(sd_from_cstring->Length(), sd_from_string->Length());
8632 CHECK_EQ(0, memcmp(sd_from_cstring->Data(),
8633 sd_from_string->Data(),
8634 sd_from_cstring->Length()));
8635
8636
8627 delete sd_from_cstring; 8637 delete sd_from_cstring;
8628 delete sd_from_istring; 8638 delete sd_from_external_string;
8639 delete sd_from_string;
8629 } 8640 }
8630 8641
8631 8642
8632 // This tests that we do not allow dictionary load/call inline caches 8643 // This tests that we do not allow dictionary load/call inline caches
8633 // to use functions that have not yet been compiled. The potential 8644 // to use functions that have not yet been compiled. The potential
8634 // problem of loading a function that has not yet been compiled can 8645 // problem of loading a function that has not yet been compiled can
8635 // arise because we share code between contexts via the compilation 8646 // arise because we share code between contexts via the compilation
8636 // cache. 8647 // cache.
8637 THREADED_TEST(DictionaryICLoadedFunction) { 8648 THREADED_TEST(DictionaryICLoadedFunction) {
8638 v8::HandleScope scope; 8649 v8::HandleScope scope;
(...skipping 2507 matching lines...) Expand 10 before | Expand all | Expand 10 after
11146 11157
11147 ExpectString("str2.substring(2, 10);", "elspenda"); 11158 ExpectString("str2.substring(2, 10);", "elspenda");
11148 11159
11149 ExpectString("str2.substring(2, 20);", "elspendabelabelspe"); 11160 ExpectString("str2.substring(2, 20);", "elspendabelabelspe");
11150 11161
11151 ExpectString("str2.charAt(2);", "e"); 11162 ExpectString("str2.charAt(2);", "e");
11152 11163
11153 reresult = CompileRun("str2.charCodeAt(2);"); 11164 reresult = CompileRun("str2.charCodeAt(2);");
11154 CHECK_EQ(static_cast<int32_t>('e'), reresult->Int32Value()); 11165 CHECK_EQ(static_cast<int32_t>('e'), reresult->Int32Value());
11155 } 11166 }
OLDNEW
« no previous file with comments | « src/scanner.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698