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 2234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2245 CHECK(obj->Has(sym1)); | 2245 CHECK(obj->Has(sym1)); |
2246 CHECK(obj->Has(sym2)); | 2246 CHECK(obj->Has(sym2)); |
2247 CHECK(obj->Delete(sym2)); | 2247 CHECK(obj->Delete(sym2)); |
2248 CHECK(obj->Has(sym1)); | 2248 CHECK(obj->Has(sym1)); |
2249 CHECK(!obj->Has(sym2)); | 2249 CHECK(!obj->Has(sym2)); |
2250 CHECK_EQ(2002, obj->Get(sym1)->Int32Value()); | 2250 CHECK_EQ(2002, obj->Get(sym1)->Int32Value()); |
2251 CHECK_EQ(1, obj->GetOwnPropertyNames()->Length()); | 2251 CHECK_EQ(1, obj->GetOwnPropertyNames()->Length()); |
2252 } | 2252 } |
2253 | 2253 |
2254 | 2254 |
| 2255 THREADED_TEST(ArrayBuffer) { |
| 2256 i::FLAG_harmony_typed_arrays = true; |
| 2257 |
| 2258 LocalContext env; |
| 2259 v8::Isolate* isolate = env->GetIsolate(); |
| 2260 v8::HandleScope handle_scope(isolate); |
| 2261 |
| 2262 Local<v8::ArrayBuffer> ab = v8::ArrayBuffer::New(1024); |
| 2263 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 2264 |
| 2265 CHECK_EQ(1024, ab->ByteLength()); |
| 2266 uint8_t* data = static_cast<uint8_t*>(ab->Data()); |
| 2267 ASSERT(data != NULL); |
| 2268 env->Global()->Set(v8_str("ab"), ab); |
| 2269 |
| 2270 v8::Handle<v8::Value> result = CompileRun("ab.byteLength"); |
| 2271 CHECK_EQ(1024, result->Int32Value()); |
| 2272 |
| 2273 result = CompileRun("var u8 = new __Uint8Array(ab);" |
| 2274 "u8[0] = 0xFF;" |
| 2275 "u8[1] = 0xAA;" |
| 2276 "u8.length"); |
| 2277 CHECK_EQ(1024, result->Int32Value()); |
| 2278 CHECK_EQ(0xFF, data[0]); |
| 2279 CHECK_EQ(0xAA, data[1]); |
| 2280 data[0] = 0xCC; |
| 2281 data[1] = 0x11; |
| 2282 result = CompileRun("u8[0] + u8[1]"); |
| 2283 CHECK_EQ(0xDD, result->Int32Value()); |
| 2284 |
| 2285 result = CompileRun("var ab1 = new __ArrayBuffer(2);" |
| 2286 "var u8_a = new __Uint8Array(ab1);" |
| 2287 "u8_a[0] = 0xAA;" |
| 2288 "u8_a[1] = 0xFF; u8_a.buffer"); |
| 2289 Local<v8::ArrayBuffer> ab1 = v8::ArrayBuffer::Cast(*result); |
| 2290 CHECK_EQ(2, ab1->ByteLength()); |
| 2291 uint8_t* ab1_data = static_cast<uint8_t*>(ab1->Data()); |
| 2292 CHECK_EQ(0xAA, ab1_data[0]); |
| 2293 CHECK_EQ(0xFF, ab1_data[1]); |
| 2294 ab1_data[0] = 0xCC; |
| 2295 ab1_data[1] = 0x11; |
| 2296 result = CompileRun("u8_a[0] + u8_a[1]"); |
| 2297 CHECK_EQ(0xDD, result->Int32Value()); |
| 2298 |
| 2299 uint8_t* my_data = new uint8_t[100]; |
| 2300 memset(my_data, 0, 100); |
| 2301 Local<v8::ArrayBuffer> ab3 = v8::ArrayBuffer::New(my_data, 100); |
| 2302 CHECK_EQ(100, ab3->ByteLength()); |
| 2303 CHECK_EQ(my_data, ab3->Data()); |
| 2304 env->Global()->Set(v8_str("ab3"), ab3); |
| 2305 result = CompileRun("var u8_b = new __Uint8Array(ab3);" |
| 2306 "u8_b[0] = 0xBB;" |
| 2307 "u8_b[1] = 0xCC;" |
| 2308 "u8_b.length"); |
| 2309 CHECK_EQ(100, result->Int32Value()); |
| 2310 CHECK_EQ(0xBB, my_data[0]); |
| 2311 CHECK_EQ(0xCC, my_data[1]); |
| 2312 my_data[0] = 0xCC; |
| 2313 my_data[1] = 0x11; |
| 2314 result = CompileRun("u8_b[0] + u8_b[1]"); |
| 2315 CHECK_EQ(0xDD, result->Int32Value()); |
| 2316 |
| 2317 |
| 2318 delete[] my_data; |
| 2319 } |
| 2320 |
| 2321 |
2255 THREADED_TEST(HiddenProperties) { | 2322 THREADED_TEST(HiddenProperties) { |
2256 LocalContext env; | 2323 LocalContext env; |
2257 v8::HandleScope scope(env->GetIsolate()); | 2324 v8::HandleScope scope(env->GetIsolate()); |
2258 | 2325 |
2259 v8::Local<v8::Object> obj = v8::Object::New(); | 2326 v8::Local<v8::Object> obj = v8::Object::New(); |
2260 v8::Local<v8::String> key = v8_str("api-test::hidden-key"); | 2327 v8::Local<v8::String> key = v8_str("api-test::hidden-key"); |
2261 v8::Local<v8::String> empty = v8_str(""); | 2328 v8::Local<v8::String> empty = v8_str(""); |
2262 v8::Local<v8::String> prop_name = v8_str("prop_name"); | 2329 v8::Local<v8::String> prop_name = v8_str("prop_name"); |
2263 | 2330 |
2264 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 2331 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
(...skipping 16129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
18394 i::Semaphore* sem_; | 18461 i::Semaphore* sem_; |
18395 volatile int sem_value_; | 18462 volatile int sem_value_; |
18396 }; | 18463 }; |
18397 | 18464 |
18398 | 18465 |
18399 THREADED_TEST(SemaphoreInterruption) { | 18466 THREADED_TEST(SemaphoreInterruption) { |
18400 ThreadInterruptTest().RunTest(); | 18467 ThreadInterruptTest().RunTest(); |
18401 } | 18468 } |
18402 | 18469 |
18403 #endif // WIN32 | 18470 #endif // WIN32 |
OLD | NEW |