Chromium Code Reviews| 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)) | |
|
Lasse Reichstein
2009/10/02 20:01:23
It seems counter-intuitive to have a macro called
| |
| 707 #else | |
| 708 # define CAST_TO_INT64(x) (int64_t(x)) | |
| 709 #endif | |
| 710 | |
| 705 THREADED_TEST(TinyInteger) { | 711 THREADED_TEST(TinyInteger) { |
| 706 v8::HandleScope scope; | 712 v8::HandleScope scope; |
| 707 LocalContext env; | 713 LocalContext env; |
| 708 int32_t value = 239; | 714 int32_t value = 239; |
| 709 Local<v8::Integer> value_obj = v8::Integer::New(value); | 715 Local<v8::Integer> value_obj = v8::Integer::New(value); |
| 710 CHECK_EQ(int64_t(value), value_obj->Value()); | 716 CHECK_EQ(CAST_TO_INT64(value), value_obj->Value()); |
| 711 } | 717 } |
| 712 | 718 |
| 713 | 719 |
| 714 THREADED_TEST(BigSmiInteger) { | 720 THREADED_TEST(BigSmiInteger) { |
| 715 v8::HandleScope scope; | 721 v8::HandleScope scope; |
| 716 LocalContext env; | 722 LocalContext env; |
| 717 int32_t value = (1 << 30) - 1; | 723 int32_t value = (1 << 30) - 1; |
| 718 CHECK(i::Smi::IsValid(value)); | 724 CHECK(i::Smi::IsValid(value)); |
| 719 CHECK(!i::Smi::IsValid(value + 1)); | 725 CHECK(!i::Smi::IsValid(value + 1)); |
| 720 Local<v8::Integer> value_obj = v8::Integer::New(value); | 726 Local<v8::Integer> value_obj = v8::Integer::New(value); |
| 721 CHECK_EQ(int64_t(value), value_obj->Value()); | 727 CHECK_EQ(CAST_TO_INT64(value), value_obj->Value()); |
| 722 } | 728 } |
| 723 | 729 |
| 724 | 730 |
| 725 THREADED_TEST(BigInteger) { | 731 THREADED_TEST(BigInteger) { |
| 726 v8::HandleScope scope; | 732 v8::HandleScope scope; |
| 727 LocalContext env; | 733 LocalContext env; |
| 728 int32_t value = (1 << 30) + 1; | 734 int32_t value = (1 << 30) + 1; |
| 729 CHECK(!i::Smi::IsValid(value)); | 735 CHECK(!i::Smi::IsValid(value)); |
| 730 Local<v8::Integer> value_obj = v8::Integer::New(value); | 736 Local<v8::Integer> value_obj = v8::Integer::New(value); |
| 731 CHECK_EQ(int64_t(value), value_obj->Value()); | 737 CHECK_EQ(CAST_TO_INT64(value), value_obj->Value()); |
| 732 } | 738 } |
| 733 | 739 |
| 734 | 740 |
| 735 THREADED_TEST(TinyUnsignedInteger) { | 741 THREADED_TEST(TinyUnsignedInteger) { |
| 736 v8::HandleScope scope; | 742 v8::HandleScope scope; |
| 737 LocalContext env; | 743 LocalContext env; |
| 738 uint32_t value = 239; | 744 uint32_t value = 239; |
| 739 Local<v8::Integer> value_obj = v8::Integer::New(value); | 745 Local<v8::Integer> value_obj = v8::Integer::New(value); |
| 740 CHECK_EQ(int64_t(value), value_obj->Value()); | 746 CHECK_EQ(CAST_TO_INT64(value), value_obj->Value()); |
| 741 } | 747 } |
| 742 | 748 |
| 743 | 749 |
| 744 THREADED_TEST(BigUnsignedSmiInteger) { | 750 THREADED_TEST(BigUnsignedSmiInteger) { |
| 745 v8::HandleScope scope; | 751 v8::HandleScope scope; |
| 746 LocalContext env; | 752 LocalContext env; |
| 747 uint32_t value = (1 << 30) - 1; | 753 uint32_t value = (1 << 30) - 1; |
| 748 CHECK(i::Smi::IsValid(value)); | 754 CHECK(i::Smi::IsValid(value)); |
| 749 CHECK(!i::Smi::IsValid(value + 1)); | 755 CHECK(!i::Smi::IsValid(value + 1)); |
| 750 Local<v8::Integer> value_obj = v8::Integer::New(value); | 756 Local<v8::Integer> value_obj = v8::Integer::New(value); |
| 751 CHECK_EQ(int64_t(value), value_obj->Value()); | 757 CHECK_EQ(CAST_TO_INT64(value), value_obj->Value()); |
| 752 } | 758 } |
| 753 | 759 |
| 754 | 760 |
| 755 THREADED_TEST(BigUnsignedInteger) { | 761 THREADED_TEST(BigUnsignedInteger) { |
| 756 v8::HandleScope scope; | 762 v8::HandleScope scope; |
| 757 LocalContext env; | 763 LocalContext env; |
| 758 uint32_t value = (1 << 30) + 1; | 764 uint32_t value = (1 << 30) + 1; |
| 759 CHECK(!i::Smi::IsValid(value)); | 765 CHECK(!i::Smi::IsValid(value)); |
| 760 Local<v8::Integer> value_obj = v8::Integer::New(value); | 766 Local<v8::Integer> value_obj = v8::Integer::New(value); |
| 761 CHECK_EQ(int64_t(value), value_obj->Value()); | 767 CHECK_EQ(CAST_TO_INT64(value), value_obj->Value()); |
| 762 } | 768 } |
| 763 | 769 |
| 764 | 770 |
| 765 THREADED_TEST(OutOfSignedRangeUnsignedInteger) { | 771 THREADED_TEST(OutOfSignedRangeUnsignedInteger) { |
| 766 v8::HandleScope scope; | 772 v8::HandleScope scope; |
| 767 LocalContext env; | 773 LocalContext env; |
| 768 uint32_t value = uint32_t(0xffffffff); | 774 uint32_t value = uint32_t(0xffffffff); |
| 769 Local<v8::Integer> value_obj = v8::Integer::New(value); | 775 Local<v8::Integer> value_obj = v8::Integer::New(value); |
| 770 CHECK_EQ(int64_t(value), value_obj->Value()); | 776 CHECK_EQ(CAST_TO_INT64(value), value_obj->Value()); |
| 771 } | 777 } |
| 772 | 778 |
| 773 | 779 |
| 774 THREADED_TEST(Number) { | 780 THREADED_TEST(Number) { |
| 775 v8::HandleScope scope; | 781 v8::HandleScope scope; |
| 776 LocalContext env; | 782 LocalContext env; |
| 777 double PI = 3.1415926; | 783 double PI = 3.1415926; |
| 778 Local<v8::Number> pi_obj = v8::Number::New(PI); | 784 Local<v8::Number> pi_obj = v8::Number::New(PI); |
| 779 CHECK_EQ(PI, pi_obj->NumberValue()); | 785 CHECK_EQ(PI, pi_obj->NumberValue()); |
| 780 } | 786 } |
| (...skipping 7274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8055 env->Global()->Set(v8_str("get_stack_limit"), fun); | 8061 env->Global()->Set(v8_str("get_stack_limit"), fun); |
| 8056 CompileRun("get_stack_limit();"); | 8062 CompileRun("get_stack_limit();"); |
| 8057 | 8063 |
| 8058 CHECK(stack_limit == set_limit); | 8064 CHECK(stack_limit == set_limit); |
| 8059 } | 8065 } |
| 8060 { | 8066 { |
| 8061 v8::Locker locker; | 8067 v8::Locker locker; |
| 8062 CHECK(stack_limit == set_limit); | 8068 CHECK(stack_limit == set_limit); |
| 8063 } | 8069 } |
| 8064 } | 8070 } |
| OLD | NEW |