| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 10 matching lines...) Expand all Loading... |
| 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #include <climits> | 28 #include <climits> |
| 29 #include <csignal> | 29 #include <csignal> |
| 30 #include <map> | 30 #include <map> |
| 31 #include <memory> |
| 31 #include <string> | 32 #include <string> |
| 32 | 33 |
| 33 #include "test/cctest/test-api.h" | 34 #include "test/cctest/test-api.h" |
| 34 | 35 |
| 35 #if V8_OS_POSIX | 36 #if V8_OS_POSIX |
| 36 #include <unistd.h> // NOLINT | 37 #include <unistd.h> // NOLINT |
| 37 #endif | 38 #endif |
| 38 | 39 |
| 39 #include "include/v8-util.h" | 40 #include "include/v8-util.h" |
| 40 #include "src/api.h" | 41 #include "src/api.h" |
| (...skipping 19215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 19256 | 19257 |
| 19257 | 19258 |
| 19258 TEST(ContainsOnlyOneByte) { | 19259 TEST(ContainsOnlyOneByte) { |
| 19259 v8::V8::Initialize(); | 19260 v8::V8::Initialize(); |
| 19260 v8::Isolate* isolate = CcTest::isolate(); | 19261 v8::Isolate* isolate = CcTest::isolate(); |
| 19261 v8::HandleScope scope(isolate); | 19262 v8::HandleScope scope(isolate); |
| 19262 // Make a buffer long enough that it won't automatically be converted. | 19263 // Make a buffer long enough that it won't automatically be converted. |
| 19263 const int length = 512; | 19264 const int length = 512; |
| 19264 // Ensure word aligned assignment. | 19265 // Ensure word aligned assignment. |
| 19265 const int aligned_length = length*sizeof(uintptr_t)/sizeof(uint16_t); | 19266 const int aligned_length = length*sizeof(uintptr_t)/sizeof(uint16_t); |
| 19266 v8::base::SmartArrayPointer<uintptr_t> aligned_contents( | 19267 std::unique_ptr<uintptr_t[]> aligned_contents(new uintptr_t[aligned_length]); |
| 19267 new uintptr_t[aligned_length]); | |
| 19268 uint16_t* string_contents = | 19268 uint16_t* string_contents = |
| 19269 reinterpret_cast<uint16_t*>(aligned_contents.get()); | 19269 reinterpret_cast<uint16_t*>(aligned_contents.get()); |
| 19270 // Set to contain only one byte. | 19270 // Set to contain only one byte. |
| 19271 for (int i = 0; i < length-1; i++) { | 19271 for (int i = 0; i < length-1; i++) { |
| 19272 string_contents[i] = 0x41; | 19272 string_contents[i] = 0x41; |
| 19273 } | 19273 } |
| 19274 string_contents[length-1] = 0; | 19274 string_contents[length-1] = 0; |
| 19275 // Simple case. | 19275 // Simple case. |
| 19276 Local<String> string = | 19276 Local<String> string = |
| 19277 String::NewExternalTwoByte(isolate, | 19277 String::NewExternalTwoByte(isolate, |
| (...skipping 6176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 25454 | 25454 |
| 25455 // Put the function into context1 and call it. Since the access check | 25455 // Put the function into context1 and call it. Since the access check |
| 25456 // callback always returns true, the call succeeds even though the tokens | 25456 // callback always returns true, the call succeeds even though the tokens |
| 25457 // are different. | 25457 // are different. |
| 25458 context1->Enter(); | 25458 context1->Enter(); |
| 25459 context1->Global()->Set(context1, v8_str("fun"), fun).FromJust(); | 25459 context1->Global()->Set(context1, v8_str("fun"), fun).FromJust(); |
| 25460 v8::Local<v8::Value> x_value = CompileRun("fun('x')"); | 25460 v8::Local<v8::Value> x_value = CompileRun("fun('x')"); |
| 25461 CHECK_EQ(42, x_value->Int32Value(context1).FromJust()); | 25461 CHECK_EQ(42, x_value->Int32Value(context1).FromJust()); |
| 25462 context1->Exit(); | 25462 context1->Exit(); |
| 25463 } | 25463 } |
| OLD | NEW |