| 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 2614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2625 CHECK_EQ(100, result->Int32Value()); | 2625 CHECK_EQ(100, result->Int32Value()); |
| 2626 CHECK_EQ(0xBB, my_data[0]); | 2626 CHECK_EQ(0xBB, my_data[0]); |
| 2627 CHECK_EQ(0xCC, my_data[1]); | 2627 CHECK_EQ(0xCC, my_data[1]); |
| 2628 my_data[0] = 0xCC; | 2628 my_data[0] = 0xCC; |
| 2629 my_data[1] = 0x11; | 2629 my_data[1] = 0x11; |
| 2630 result = CompileRun("u8_b[0] + u8_b[1]"); | 2630 result = CompileRun("u8_b[0] + u8_b[1]"); |
| 2631 CHECK_EQ(0xDD, result->Int32Value()); | 2631 CHECK_EQ(0xDD, result->Int32Value()); |
| 2632 } | 2632 } |
| 2633 | 2633 |
| 2634 | 2634 |
| 2635 THREADED_TEST(DataView) { |
| 2636 i::FLAG_harmony_data_view = true; |
| 2637 i::FLAG_harmony_typed_arrays = true; |
| 2638 |
| 2639 LocalContext env; |
| 2640 v8::Isolate* isolate = env->GetIsolate(); |
| 2641 v8::HandleScope handle_scope(isolate); |
| 2642 |
| 2643 char data[1024]; |
| 2644 const int kByteOffset = 256; |
| 2645 const int kByteLength = sizeof(data) - kByteOffset; |
| 2646 |
| 2647 Local<v8::ArrayBuffer> array_buffer = |
| 2648 v8::ArrayBuffer::New(data, sizeof(data)); |
| 2649 Local<v8::DataView> data_view = |
| 2650 v8::DataView::New(array_buffer, kByteOffset, kByteLength); |
| 2651 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 2652 |
| 2653 CHECK_EQ(kByteOffset, data_view->ByteOffset()); |
| 2654 CHECK_EQ(kByteLength, data_view->ByteLength()); |
| 2655 CHECK_EQ(static_cast<void*>(data + kByteOffset), data_view->Data()); |
| 2656 |
| 2657 data_view->SetUint32(0, 0x12345678, false); // Big-endian |
| 2658 CHECK_EQ(0x12, data_view->GetUint8(0)); |
| 2659 CHECK_EQ(0x34, data_view->GetUint8(1)); |
| 2660 CHECK_EQ(0x56, data_view->GetUint8(2)); |
| 2661 CHECK_EQ(0x78, data_view->GetUint8(3)); |
| 2662 CHECK_EQ(0x1234, data_view->GetUint16(0)); // Big-endian |
| 2663 CHECK_EQ(0x5678, data_view->GetUint16(2)); // Big-endian |
| 2664 CHECK_EQ(0x1234, data_view->GetUint16(0, false)); // Big-endian |
| 2665 CHECK_EQ(0x3412, data_view->GetUint16(0, true)); // Little-endian |
| 2666 CHECK_EQ(0x5678, data_view->GetUint16(2, false)); // Big-endian |
| 2667 CHECK_EQ(0x7856, data_view->GetUint16(2, true)); // Little-endian |
| 2668 CHECK_EQ(0x12345678, data_view->GetUint32(0)); // Big-endian |
| 2669 CHECK_EQ(0x12345678, data_view->GetUint32(0, false)); // Big-endian |
| 2670 CHECK_EQ(0x78563412, data_view->GetUint32(0, true)); // Little-endian |
| 2671 |
| 2672 data_view->SetUint32(0, 0x12345678, true); // Little-endian |
| 2673 CHECK_EQ(0x78, data_view->GetUint8(0)); |
| 2674 CHECK_EQ(0x56, data_view->GetUint8(1)); |
| 2675 CHECK_EQ(0x34, data_view->GetUint8(2)); |
| 2676 CHECK_EQ(0x12, data_view->GetUint8(3)); |
| 2677 CHECK_EQ(0x7856, data_view->GetUint16(0)); // Big-endian |
| 2678 CHECK_EQ(0x3412, data_view->GetUint16(2)); // Big-endian |
| 2679 CHECK_EQ(0x7856, data_view->GetUint16(0, false)); // Big-endian |
| 2680 CHECK_EQ(0x5678, data_view->GetUint16(0, true)); // Little-endian |
| 2681 CHECK_EQ(0x3412, data_view->GetUint16(2, false)); // Big-endian |
| 2682 CHECK_EQ(0x1234, data_view->GetUint16(2, true)); // Little-endian |
| 2683 CHECK_EQ(0x78563412, data_view->GetUint32(0)); // Big-endian. |
| 2684 CHECK_EQ(0x78563412, data_view->GetUint32(0, false)); // Big-endian. |
| 2685 CHECK_EQ(0x12345678, data_view->GetUint32(0, true)); // Little-endian. |
| 2686 |
| 2687 data_view->SetFloat32(0, 123.456f); |
| 2688 data_view->SetFloat64(4, 123.456); |
| 2689 CHECK_EQ(123.456f, data_view->GetFloat32(0)); |
| 2690 CHECK_EQ(123.456, data_view->GetFloat64(4)); |
| 2691 } |
| 2692 |
| 2693 |
| 2635 THREADED_TEST(HiddenProperties) { | 2694 THREADED_TEST(HiddenProperties) { |
| 2636 LocalContext env; | 2695 LocalContext env; |
| 2637 v8::HandleScope scope(env->GetIsolate()); | 2696 v8::HandleScope scope(env->GetIsolate()); |
| 2638 | 2697 |
| 2639 v8::Local<v8::Object> obj = v8::Object::New(); | 2698 v8::Local<v8::Object> obj = v8::Object::New(); |
| 2640 v8::Local<v8::String> key = v8_str("api-test::hidden-key"); | 2699 v8::Local<v8::String> key = v8_str("api-test::hidden-key"); |
| 2641 v8::Local<v8::String> empty = v8_str(""); | 2700 v8::Local<v8::String> empty = v8_str(""); |
| 2642 v8::Local<v8::String> prop_name = v8_str("prop_name"); | 2701 v8::Local<v8::String> prop_name = v8_str("prop_name"); |
| 2643 | 2702 |
| 2644 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 2703 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
| (...skipping 16430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 19075 i::Semaphore* sem_; | 19134 i::Semaphore* sem_; |
| 19076 volatile int sem_value_; | 19135 volatile int sem_value_; |
| 19077 }; | 19136 }; |
| 19078 | 19137 |
| 19079 | 19138 |
| 19080 THREADED_TEST(SemaphoreInterruption) { | 19139 THREADED_TEST(SemaphoreInterruption) { |
| 19081 ThreadInterruptTest().RunTest(); | 19140 ThreadInterruptTest().RunTest(); |
| 19082 } | 19141 } |
| 19083 | 19142 |
| 19084 #endif // WIN32 | 19143 #endif // WIN32 |
| OLD | NEW |