OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <stdlib.h> | 5 #include <stdlib.h> |
6 | 6 |
7 #include "src/v8.h" | 7 #include "src/v8.h" |
8 #include "test/cctest/cctest.h" | 8 #include "test/cctest/cctest.h" |
9 | 9 |
10 #include "src/api.h" | 10 #include "src/api.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 "a[2] = 2;" | 41 "a[2] = 2;" |
42 "a[3] = 3;"); | 42 "a[3] = 3;"); |
43 TestArrayBufferViewContents(env, false); | 43 TestArrayBufferViewContents(env, false); |
44 } | 44 } |
45 | 45 |
46 | 46 |
47 TEST(CopyContentsArray) { | 47 TEST(CopyContentsArray) { |
48 LocalContext env; | 48 LocalContext env; |
49 v8::HandleScope scope(env->GetIsolate()); | 49 v8::HandleScope scope(env->GetIsolate()); |
50 CompileRun("var a = new Uint8Array([0, 1, 2, 3]);"); | 50 CompileRun("var a = new Uint8Array([0, 1, 2, 3]);"); |
51 TestArrayBufferViewContents(env, true); | 51 TestArrayBufferViewContents(env, false); |
52 } | 52 } |
53 | 53 |
54 | 54 |
55 TEST(CopyContentsView) { | 55 TEST(CopyContentsView) { |
56 LocalContext env; | 56 LocalContext env; |
57 v8::HandleScope scope(env->GetIsolate()); | 57 v8::HandleScope scope(env->GetIsolate()); |
58 CompileRun( | 58 CompileRun( |
59 "var b = new ArrayBuffer(6);" | 59 "var b = new ArrayBuffer(6);" |
60 "var c = new Uint8Array(b);" | 60 "var c = new Uint8Array(b);" |
61 "c[0] = -1;" | 61 "c[0] = -1;" |
(...skipping 12 matching lines...) Expand all Loading... |
74 v8::HandleScope scope(env->GetIsolate()); | 74 v8::HandleScope scope(env->GetIsolate()); |
75 void* memory = reinterpret_cast<Isolate*>(env->GetIsolate()) | 75 void* memory = reinterpret_cast<Isolate*>(env->GetIsolate()) |
76 ->array_buffer_allocator() | 76 ->array_buffer_allocator() |
77 ->Allocate(1024); | 77 ->Allocate(1024); |
78 v8::Local<v8::ArrayBuffer> buffer = | 78 v8::Local<v8::ArrayBuffer> buffer = |
79 v8::ArrayBuffer::New(env->GetIsolate(), memory, 1024, | 79 v8::ArrayBuffer::New(env->GetIsolate(), memory, 1024, |
80 v8::ArrayBufferCreationMode::kInternalized); | 80 v8::ArrayBufferCreationMode::kInternalized); |
81 CHECK(!buffer->IsExternal()); | 81 CHECK(!buffer->IsExternal()); |
82 CHECK_EQ(memory, buffer->GetContents().Data()); | 82 CHECK_EQ(memory, buffer->GetContents().Data()); |
83 } | 83 } |
OLD | NEW |