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 THREADED_TEST(TinyInteger) { |
| 706 v8::HandleScope scope; |
| 707 LocalContext env; |
| 708 int32_t value = 239; |
| 709 Local<v8::Integer> value_obj = v8::Integer::New(value); |
| 710 CHECK_EQ(int64_t(value), value_obj->Value()); |
| 711 } |
| 712 |
| 713 |
| 714 THREADED_TEST(BigSmiInteger) { |
| 715 v8::HandleScope scope; |
| 716 LocalContext env; |
| 717 int32_t value = (1 << 30) - 1; |
| 718 CHECK(i::Smi::IsValid(value)); |
| 719 CHECK(!i::Smi::IsValid(value + 1)); |
| 720 Local<v8::Integer> value_obj = v8::Integer::New(value); |
| 721 CHECK_EQ(int64_t(value), value_obj->Value()); |
| 722 } |
| 723 |
| 724 |
| 725 THREADED_TEST(BigInteger) { |
| 726 v8::HandleScope scope; |
| 727 LocalContext env; |
| 728 int32_t value = (1 << 30) + 1; |
| 729 CHECK(!i::Smi::IsValid(value)); |
| 730 Local<v8::Integer> value_obj = v8::Integer::New(value); |
| 731 CHECK_EQ(int64_t(value), value_obj->Value()); |
| 732 } |
| 733 |
| 734 |
| 735 THREADED_TEST(TinyUnsignedInteger) { |
| 736 v8::HandleScope scope; |
| 737 LocalContext env; |
| 738 uint32_t value = 239; |
| 739 Local<v8::Integer> value_obj = v8::Integer::New(value); |
| 740 CHECK_EQ(int64_t(value), value_obj->Value()); |
| 741 } |
| 742 |
| 743 |
| 744 THREADED_TEST(BigUnsignedSmiInteger) { |
| 745 v8::HandleScope scope; |
| 746 LocalContext env; |
| 747 uint32_t value = (1 << 30) - 1; |
| 748 CHECK(i::Smi::IsValid(value)); |
| 749 CHECK(!i::Smi::IsValid(value + 1)); |
| 750 Local<v8::Integer> value_obj = v8::Integer::New(value); |
| 751 CHECK_EQ(int64_t(value), value_obj->Value()); |
| 752 } |
| 753 |
| 754 |
| 755 THREADED_TEST(BigUnsignedInteger) { |
| 756 v8::HandleScope scope; |
| 757 LocalContext env; |
| 758 uint32_t value = (1 << 30) + 1; |
| 759 CHECK(!i::Smi::IsValid(value)); |
| 760 Local<v8::Integer> value_obj = v8::Integer::New(value); |
| 761 CHECK_EQ(int64_t(value), value_obj->Value()); |
| 762 } |
| 763 |
| 764 |
| 765 THREADED_TEST(OutOfSignedRangeUnsignedInteger) { |
| 766 v8::HandleScope scope; |
| 767 LocalContext env; |
| 768 uint32_t value = uint32_t(0xffffffff); |
| 769 Local<v8::Integer> value_obj = v8::Integer::New(value); |
| 770 CHECK_EQ(int64_t(value), value_obj->Value()); |
| 771 } |
| 772 |
| 773 |
705 THREADED_TEST(Number) { | 774 THREADED_TEST(Number) { |
706 v8::HandleScope scope; | 775 v8::HandleScope scope; |
707 LocalContext env; | 776 LocalContext env; |
708 double PI = 3.1415926; | 777 double PI = 3.1415926; |
709 Local<v8::Number> pi_obj = v8::Number::New(PI); | 778 Local<v8::Number> pi_obj = v8::Number::New(PI); |
710 CHECK_EQ(PI, pi_obj->NumberValue()); | 779 CHECK_EQ(PI, pi_obj->NumberValue()); |
711 } | 780 } |
712 | 781 |
713 | 782 |
714 THREADED_TEST(ToNumber) { | 783 THREADED_TEST(ToNumber) { |
(...skipping 7271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7986 env->Global()->Set(v8_str("get_stack_limit"), fun); | 8055 env->Global()->Set(v8_str("get_stack_limit"), fun); |
7987 CompileRun("get_stack_limit();"); | 8056 CompileRun("get_stack_limit();"); |
7988 | 8057 |
7989 CHECK(stack_limit == set_limit); | 8058 CHECK(stack_limit == set_limit); |
7990 } | 8059 } |
7991 { | 8060 { |
7992 v8::Locker locker; | 8061 v8::Locker locker; |
7993 CHECK(stack_limit == set_limit); | 8062 CHECK(stack_limit == set_limit); |
7994 } | 8063 } |
7995 } | 8064 } |
OLD | NEW |