OLD | NEW |
1 // Copyright 2007-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2009 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 684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
695 LocalContext env; | 695 LocalContext env; |
696 Local<Function> fun = fun_templ->GetFunction(); | 696 Local<Function> fun = fun_templ->GetFunction(); |
697 env->Global()->Set(v8_str("Fun"), fun); | 697 env->Global()->Set(v8_str("Fun"), fun); |
698 Local<Script> getter = v8_compile("var obj = new Fun(); obj.foo;"); | 698 Local<Script> getter = v8_compile("var obj = new Fun(); obj.foo;"); |
699 CHECK_EQ(900, getter->Run()->Int32Value()); | 699 CHECK_EQ(900, getter->Run()->Int32Value()); |
700 Local<Script> setter = v8_compile("obj.foo = 901;"); | 700 Local<Script> setter = v8_compile("obj.foo = 901;"); |
701 CHECK_EQ(901, setter->Run()->Int32Value()); | 701 CHECK_EQ(901, setter->Run()->Int32Value()); |
702 } | 702 } |
703 | 703 |
704 | 704 |
705 #if V8_HOST_ARCH_64_BIT | |
706 # define CAST_TO_INT64(x) (int(x)) | |
707 #else | |
708 # define CAST_TO_INT64(x) (int64_t(x)) | |
709 #endif | |
710 | |
711 THREADED_TEST(TinyInteger) { | 705 THREADED_TEST(TinyInteger) { |
712 v8::HandleScope scope; | 706 v8::HandleScope scope; |
713 LocalContext env; | 707 LocalContext env; |
714 int32_t value = 239; | 708 int32_t value = 239; |
715 Local<v8::Integer> value_obj = v8::Integer::New(value); | 709 Local<v8::Integer> value_obj = v8::Integer::New(value); |
716 CHECK_EQ(CAST_TO_INT64(value), value_obj->Value()); | 710 CHECK_INT64_EQ(static_cast<int64_t>(value), value_obj->Value()); |
717 } | 711 } |
718 | 712 |
719 | 713 |
720 THREADED_TEST(BigSmiInteger) { | 714 THREADED_TEST(BigSmiInteger) { |
721 v8::HandleScope scope; | 715 v8::HandleScope scope; |
722 LocalContext env; | 716 LocalContext env; |
723 int32_t value = (1 << 30) - 1; | 717 int32_t value = (1 << 30) - 1; |
724 CHECK(i::Smi::IsValid(value)); | 718 CHECK(i::Smi::IsValid(value)); |
725 CHECK(!i::Smi::IsValid(value + 1)); | 719 CHECK(!i::Smi::IsValid(value + 1)); |
726 Local<v8::Integer> value_obj = v8::Integer::New(value); | 720 Local<v8::Integer> value_obj = v8::Integer::New(value); |
727 CHECK_EQ(CAST_TO_INT64(value), value_obj->Value()); | 721 CHECK_INT64_EQ(static_cast<int64_t>(value), value_obj->Value()); |
728 } | 722 } |
729 | 723 |
730 | 724 |
731 THREADED_TEST(BigInteger) { | 725 THREADED_TEST(BigInteger) { |
732 v8::HandleScope scope; | 726 v8::HandleScope scope; |
733 LocalContext env; | 727 LocalContext env; |
734 int32_t value = (1 << 30) + 1; | 728 int32_t value = (1 << 30) + 1; |
735 CHECK(!i::Smi::IsValid(value)); | 729 CHECK(!i::Smi::IsValid(value)); |
736 Local<v8::Integer> value_obj = v8::Integer::New(value); | 730 Local<v8::Integer> value_obj = v8::Integer::New(value); |
737 CHECK_EQ(CAST_TO_INT64(value), value_obj->Value()); | 731 CHECK_INT64_EQ(static_cast<int64_t>(value), value_obj->Value()); |
738 } | 732 } |
739 | 733 |
740 | 734 |
741 THREADED_TEST(TinyUnsignedInteger) { | 735 THREADED_TEST(TinyUnsignedInteger) { |
742 v8::HandleScope scope; | 736 v8::HandleScope scope; |
743 LocalContext env; | 737 LocalContext env; |
744 uint32_t value = 239; | 738 uint32_t value = 239; |
745 Local<v8::Integer> value_obj = v8::Integer::New(value); | 739 Local<v8::Integer> value_obj = v8::Integer::New(value); |
746 CHECK_EQ(CAST_TO_INT64(value), value_obj->Value()); | 740 CHECK_INT64_EQ(static_cast<int64_t>(value), value_obj->Value()); |
747 } | 741 } |
748 | 742 |
749 | 743 |
750 THREADED_TEST(BigUnsignedSmiInteger) { | 744 THREADED_TEST(BigUnsignedSmiInteger) { |
751 v8::HandleScope scope; | 745 v8::HandleScope scope; |
752 LocalContext env; | 746 LocalContext env; |
753 uint32_t value = (1 << 30) - 1; | 747 uint32_t value = (1 << 30) - 1; |
754 CHECK(i::Smi::IsValid(value)); | 748 CHECK(i::Smi::IsValid(value)); |
755 CHECK(!i::Smi::IsValid(value + 1)); | 749 CHECK(!i::Smi::IsValid(value + 1)); |
756 Local<v8::Integer> value_obj = v8::Integer::New(value); | 750 Local<v8::Integer> value_obj = v8::Integer::New(value); |
757 CHECK_EQ(CAST_TO_INT64(value), value_obj->Value()); | 751 CHECK_INT64_EQ(static_cast<int64_t>(value), value_obj->Value()); |
758 } | 752 } |
759 | 753 |
760 | 754 |
761 THREADED_TEST(BigUnsignedInteger) { | 755 THREADED_TEST(BigUnsignedInteger) { |
762 v8::HandleScope scope; | 756 v8::HandleScope scope; |
763 LocalContext env; | 757 LocalContext env; |
764 uint32_t value = (1 << 30) + 1; | 758 uint32_t value = (1 << 30) + 1; |
765 CHECK(!i::Smi::IsValid(value)); | 759 CHECK(!i::Smi::IsValid(value)); |
766 Local<v8::Integer> value_obj = v8::Integer::New(value); | 760 Local<v8::Integer> value_obj = v8::Integer::New(value); |
767 CHECK_EQ(CAST_TO_INT64(value), value_obj->Value()); | 761 CHECK_INT64_EQ(static_cast<int64_t>(value), value_obj->Value()); |
768 } | 762 } |
769 | 763 |
770 | 764 |
771 THREADED_TEST(OutOfSignedRangeUnsignedInteger) { | 765 THREADED_TEST(OutOfSignedRangeUnsignedInteger) { |
772 v8::HandleScope scope; | 766 v8::HandleScope scope; |
773 LocalContext env; | 767 LocalContext env; |
774 uint32_t value = uint32_t(0xffffffff); | 768 uint32_t value = uint32_t(0xffffffff); |
775 Local<v8::Integer> value_obj = v8::Integer::New(value); | 769 Local<v8::Integer> value_obj = v8::Integer::New(value); |
776 CHECK_EQ(CAST_TO_INT64(value), value_obj->Value()); | 770 CHECK_INT64_EQ(static_cast<int64_t>(value), value_obj->Value()); |
777 } | 771 } |
778 | 772 |
779 | 773 |
780 THREADED_TEST(Number) { | 774 THREADED_TEST(Number) { |
781 v8::HandleScope scope; | 775 v8::HandleScope scope; |
782 LocalContext env; | 776 LocalContext env; |
783 double PI = 3.1415926; | 777 double PI = 3.1415926; |
784 Local<v8::Number> pi_obj = v8::Number::New(PI); | 778 Local<v8::Number> pi_obj = v8::Number::New(PI); |
785 CHECK_EQ(PI, pi_obj->NumberValue()); | 779 CHECK_EQ(PI, pi_obj->NumberValue()); |
786 } | 780 } |
(...skipping 7274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8061 env->Global()->Set(v8_str("get_stack_limit"), fun); | 8055 env->Global()->Set(v8_str("get_stack_limit"), fun); |
8062 CompileRun("get_stack_limit();"); | 8056 CompileRun("get_stack_limit();"); |
8063 | 8057 |
8064 CHECK(stack_limit == set_limit); | 8058 CHECK(stack_limit == set_limit); |
8065 } | 8059 } |
8066 { | 8060 { |
8067 v8::Locker locker; | 8061 v8::Locker locker; |
8068 CHECK(stack_limit == set_limit); | 8062 CHECK(stack_limit == set_limit); |
8069 } | 8063 } |
8070 } | 8064 } |
OLD | NEW |