Chromium Code Reviews| 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 2232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2243 CHECK_EQ(1, obj->GetOwnPropertyNames()->Length()); | 2243 CHECK_EQ(1, obj->GetOwnPropertyNames()->Length()); |
| 2244 | 2244 |
| 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 |
|
rossberg
2013/04/25 11:00:55
Style: add extra line
Dmitry Lomov (no reviews)
2013/04/25 11:48:01
Done.
| |
| 2254 THREADED_TEST(ArrayBuffer) { | |
| 2255 i::FLAG_harmony_typed_arrays = true; | |
| 2256 | |
| 2257 LocalContext env; | |
| 2258 v8::Isolate* isolate = env->GetIsolate(); | |
| 2259 v8::HandleScope handle_scope(isolate); | |
| 2260 | |
| 2261 Local<v8::ArrayBuffer> ab = v8::ArrayBuffer::New(1024); | |
| 2262 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | |
| 2263 | |
| 2264 CHECK_EQ(1024, ab->ByteLength()); | |
| 2265 uint8_t* data = static_cast<uint8_t*>(ab->Data()); | |
|
rossberg
2013/04/25 11:00:55
Maybe add an assertion that Data is non-null.
Dmitry Lomov (no reviews)
2013/04/25 11:48:01
Done.
| |
| 2266 env->Global()->Set(v8_str("ab"), ab); | |
| 2267 | |
| 2268 v8::Handle<v8::Value> result = CompileRun("ab.byteLength"); | |
| 2269 CHECK_EQ(1024, result->Int32Value()); | |
| 2270 | |
| 2271 result = CompileRun("var u8 = new __Uint8Array(ab);" | |
| 2272 "u8[0] = 0xFF;" | |
| 2273 "u8[1] = 0xAA;" | |
| 2274 "u8.length"); | |
| 2275 CHECK_EQ(1024, result->Int32Value()); | |
| 2276 CHECK_EQ(0xFF, data[0]); | |
| 2277 CHECK_EQ(0xAA, data[1]); | |
|
rossberg
2013/04/25 11:00:55
Also test the inverse, i.e., writing to data, read
Dmitry Lomov (no reviews)
2013/04/25 11:48:01
Done.
| |
| 2278 | |
| 2279 result = CompileRun("var ab1 = new __ArrayBuffer(2);" | |
| 2280 "var u8_a = new __Uint8Array(ab1);" | |
| 2281 "u8_a[0] = 0xAA;" | |
| 2282 "u8_a[1] = 0xFF; u8_a.buffer"); | |
| 2283 Local<v8::ArrayBuffer> ab1 = v8::ArrayBuffer::Cast(*result); | |
| 2284 CHECK_EQ(2, ab1->ByteLength()); | |
| 2285 CHECK_EQ(0xAA, static_cast<uint8_t*>(ab1->Data())[0]); | |
| 2286 CHECK_EQ(0xFF, static_cast<uint8_t*>(ab1->Data())[1]); | |
| 2287 | |
| 2288 uint8_t* my_data = new uint8_t[100]; | |
| 2289 memset(my_data, 0, 100); | |
| 2290 Local<v8::ArrayBuffer> ab3 = v8::ArrayBuffer::New(my_data, 100); | |
| 2291 CHECK_EQ(100, ab3->ByteLength()); | |
| 2292 CHECK_EQ(my_data, ab3->Data()); | |
| 2293 | |
| 2294 env->Global()->Set(v8_str("ab3"), ab3); | |
| 2295 | |
| 2296 result = CompileRun("var u8_b = new __Uint8Array(ab3);" | |
| 2297 "u8_b[0] = 0xBB;" | |
| 2298 "u8_b[1] = 0xCC;" | |
| 2299 "u8_b.length"); | |
| 2300 CHECK_EQ(100, result->Int32Value()); | |
| 2301 CHECK_EQ(0xBB, my_data[0]); | |
| 2302 CHECK_EQ(0xCC, my_data[1]); | |
| 2303 | |
| 2304 delete[] my_data; | |
| 2305 } | |
| 2306 | |
| 2254 | 2307 |
| 2255 THREADED_TEST(HiddenProperties) { | 2308 THREADED_TEST(HiddenProperties) { |
| 2256 LocalContext env; | 2309 LocalContext env; |
| 2257 v8::HandleScope scope(env->GetIsolate()); | 2310 v8::HandleScope scope(env->GetIsolate()); |
| 2258 | 2311 |
| 2259 v8::Local<v8::Object> obj = v8::Object::New(); | 2312 v8::Local<v8::Object> obj = v8::Object::New(); |
| 2260 v8::Local<v8::String> key = v8_str("api-test::hidden-key"); | 2313 v8::Local<v8::String> key = v8_str("api-test::hidden-key"); |
| 2261 v8::Local<v8::String> empty = v8_str(""); | 2314 v8::Local<v8::String> empty = v8_str(""); |
| 2262 v8::Local<v8::String> prop_name = v8_str("prop_name"); | 2315 v8::Local<v8::String> prop_name = v8_str("prop_name"); |
| 2263 | 2316 |
| (...skipping 16130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 18394 i::Semaphore* sem_; | 18447 i::Semaphore* sem_; |
| 18395 volatile int sem_value_; | 18448 volatile int sem_value_; |
| 18396 }; | 18449 }; |
| 18397 | 18450 |
| 18398 | 18451 |
| 18399 THREADED_TEST(SemaphoreInterruption) { | 18452 THREADED_TEST(SemaphoreInterruption) { |
| 18400 ThreadInterruptTest().RunTest(); | 18453 ThreadInterruptTest().RunTest(); |
| 18401 } | 18454 } |
| 18402 | 18455 |
| 18403 #endif // WIN32 | 18456 #endif // WIN32 |
| OLD | NEW |