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 2592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2603 CHECK_EQ(100, result->Int32Value()); | 2603 CHECK_EQ(100, result->Int32Value()); |
| 2604 CHECK_EQ(0xBB, my_data[0]); | 2604 CHECK_EQ(0xBB, my_data[0]); |
| 2605 CHECK_EQ(0xCC, my_data[1]); | 2605 CHECK_EQ(0xCC, my_data[1]); |
| 2606 my_data[0] = 0xCC; | 2606 my_data[0] = 0xCC; |
| 2607 my_data[1] = 0x11; | 2607 my_data[1] = 0x11; |
| 2608 result = CompileRun("u8_b[0] + u8_b[1]"); | 2608 result = CompileRun("u8_b[0] + u8_b[1]"); |
| 2609 CHECK_EQ(0xDD, result->Int32Value()); | 2609 CHECK_EQ(0xDD, result->Int32Value()); |
| 2610 } | 2610 } |
| 2611 | 2611 |
| 2612 | 2612 |
| 2613 THREADED_TEST(DataView) { | |
| 2614 i::FLAG_harmony_data_view = true; | |
| 2615 i::FLAG_harmony_typed_arrays = true; | |
| 2616 | |
| 2617 LocalContext env; | |
| 2618 v8::Isolate* isolate = env->GetIsolate(); | |
| 2619 v8::HandleScope handle_scope(isolate); | |
| 2620 | |
| 2621 char data[1024]; | |
| 2622 const int kByteOffset = 256; | |
| 2623 const int kByteLength = sizeof(data) - kByteOffset; | |
| 2624 | |
| 2625 Local<v8::ArrayBuffer> array_buffer = | |
| 2626 v8::ArrayBuffer::New(data, sizeof(data)); | |
| 2627 Local<v8::DataView> data_view = | |
| 2628 v8::DataView::New(array_buffer, kByteOffset, kByteLength); | |
| 2629 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | |
| 2630 | |
| 2631 CHECK_EQ(kByteOffset, data_view->ByteOffset()); | |
| 2632 CHECK_EQ(kByteLength, data_view->ByteLength()); | |
| 2633 CHECK_EQ(static_cast<void*>(data + kByteOffset), data_view->Data()); | |
| 2634 | |
| 2635 data_view->SetUint32(0, 0x12345678, false); // Big-endian | |
| 2636 CHECK_EQ(0x12, data_view->GetUint8(0)); | |
| 2637 CHECK_EQ(0x34, data_view->GetUint8(1)); | |
| 2638 CHECK_EQ(0x56, data_view->GetUint8(2)); | |
| 2639 CHECK_EQ(0x78, data_view->GetUint8(3)); | |
| 2640 CHECK_EQ(0x1234, data_view->GetUint16(0)); // Big-endian | |
| 2641 CHECK_EQ(0x5678, data_view->GetUint16(2)); // Big-endian | |
| 2642 CHECK_EQ(0x1234, data_view->GetUint16(0, false)); // Big-endian | |
| 2643 CHECK_EQ(0x3412, data_view->GetUint16(0, true)); // Little-endian | |
| 2644 CHECK_EQ(0x5678, data_view->GetUint16(2, false)); // Big-endian | |
| 2645 CHECK_EQ(0x7856, data_view->GetUint16(2, true)); // Little-endian | |
| 2646 CHECK_EQ(0x12345678, data_view->GetUint32(0)); // Big-endian | |
| 2647 CHECK_EQ(0x12345678, data_view->GetUint32(0, false)); // Big-endian | |
| 2648 CHECK_EQ(0x78563412, data_view->GetUint32(0, true)); // Little-endian | |
| 2649 | |
| 2650 data_view->SetUint32(0, 0x12345678, true); // Little-endian | |
| 2651 CHECK_EQ(0x78, data_view->GetUint8(0)); | |
| 2652 CHECK_EQ(0x56, data_view->GetUint8(1)); | |
| 2653 CHECK_EQ(0x34, data_view->GetUint8(2)); | |
| 2654 CHECK_EQ(0x12, data_view->GetUint8(3)); | |
| 2655 CHECK_EQ(0x7856, data_view->GetUint16(0)); // Big-endian | |
| 2656 CHECK_EQ(0x3412, data_view->GetUint16(2)); // Big-endian | |
| 2657 CHECK_EQ(0x7856, data_view->GetUint16(0, false)); // Big-endian | |
| 2658 CHECK_EQ(0x5678, data_view->GetUint16(0, true)); // Little-endian | |
| 2659 CHECK_EQ(0x3412, data_view->GetUint16(2, false)); // Big-endian | |
| 2660 CHECK_EQ(0x1234, data_view->GetUint16(2, true)); // Little-endian | |
| 2661 CHECK_EQ(0x78563412, data_view->GetUint32(0)); // Big-endian. | |
| 2662 CHECK_EQ(0x78563412, data_view->GetUint32(0, false)); // Big-endian. | |
| 2663 CHECK_EQ(0x12345678, data_view->GetUint32(0, true)); // Little-endian. | |
| 2664 | |
| 2665 data_view->SetFloat32(0, 123.456f); | |
| 2666 data_view->SetFloat64(4, 123.456); | |
| 2667 CHECK_EQ(123.456f, data_view->GetFloat32(0)); | |
| 2668 CHECK_EQ(123.456, data_view->GetFloat64(4)); | |
|
bnoordhuis
2013/05/23 22:59:04
But if you decide to keep the API functions, there
| |
| 2669 } | |
| 2670 | |
| 2671 | |
| 2613 THREADED_TEST(HiddenProperties) { | 2672 THREADED_TEST(HiddenProperties) { |
| 2614 LocalContext env; | 2673 LocalContext env; |
| 2615 v8::HandleScope scope(env->GetIsolate()); | 2674 v8::HandleScope scope(env->GetIsolate()); |
| 2616 | 2675 |
| 2617 v8::Local<v8::Object> obj = v8::Object::New(); | 2676 v8::Local<v8::Object> obj = v8::Object::New(); |
| 2618 v8::Local<v8::String> key = v8_str("api-test::hidden-key"); | 2677 v8::Local<v8::String> key = v8_str("api-test::hidden-key"); |
| 2619 v8::Local<v8::String> empty = v8_str(""); | 2678 v8::Local<v8::String> empty = v8_str(""); |
| 2620 v8::Local<v8::String> prop_name = v8_str("prop_name"); | 2679 v8::Local<v8::String> prop_name = v8_str("prop_name"); |
| 2621 | 2680 |
| 2622 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 2681 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
| (...skipping 16678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 19301 i::Semaphore* sem_; | 19360 i::Semaphore* sem_; |
| 19302 volatile int sem_value_; | 19361 volatile int sem_value_; |
| 19303 }; | 19362 }; |
| 19304 | 19363 |
| 19305 | 19364 |
| 19306 THREADED_TEST(SemaphoreInterruption) { | 19365 THREADED_TEST(SemaphoreInterruption) { |
| 19307 ThreadInterruptTest().RunTest(); | 19366 ThreadInterruptTest().RunTest(); |
| 19308 } | 19367 } |
| 19309 | 19368 |
| 19310 #endif // WIN32 | 19369 #endif // WIN32 |
| OLD | NEW |