| 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 951 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 962 CHECK_EQ(derived_instance2, | 962 CHECK_EQ(derived_instance2, |
| 963 other_instance->FindInstanceInPrototypeChain(derived)); | 963 other_instance->FindInstanceInPrototypeChain(derived)); |
| 964 CHECK_EQ(other_instance, | 964 CHECK_EQ(other_instance, |
| 965 other_instance->FindInstanceInPrototypeChain(other)); | 965 other_instance->FindInstanceInPrototypeChain(other)); |
| 966 } | 966 } |
| 967 | 967 |
| 968 | 968 |
| 969 THREADED_TEST(TinyInteger) { | 969 THREADED_TEST(TinyInteger) { |
| 970 v8::HandleScope scope; | 970 v8::HandleScope scope; |
| 971 LocalContext env; | 971 LocalContext env; |
| 972 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 973 |
| 972 int32_t value = 239; | 974 int32_t value = 239; |
| 973 Local<v8::Integer> value_obj = v8::Integer::New(value); | 975 Local<v8::Integer> value_obj = v8::Integer::New(value); |
| 974 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); | 976 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); |
| 977 |
| 978 value_obj = v8::Integer::New(value, isolate); |
| 979 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); |
| 975 } | 980 } |
| 976 | 981 |
| 977 | 982 |
| 978 THREADED_TEST(BigSmiInteger) { | 983 THREADED_TEST(BigSmiInteger) { |
| 979 v8::HandleScope scope; | 984 v8::HandleScope scope; |
| 980 LocalContext env; | 985 LocalContext env; |
| 986 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 987 |
| 981 int32_t value = i::Smi::kMaxValue; | 988 int32_t value = i::Smi::kMaxValue; |
| 982 // We cannot add one to a Smi::kMaxValue without wrapping. | 989 // We cannot add one to a Smi::kMaxValue without wrapping. |
| 983 if (i::kSmiValueSize < 32) { | 990 if (i::kSmiValueSize < 32) { |
| 984 CHECK(i::Smi::IsValid(value)); | 991 CHECK(i::Smi::IsValid(value)); |
| 985 CHECK(!i::Smi::IsValid(value + 1)); | 992 CHECK(!i::Smi::IsValid(value + 1)); |
| 993 |
| 986 Local<v8::Integer> value_obj = v8::Integer::New(value); | 994 Local<v8::Integer> value_obj = v8::Integer::New(value); |
| 987 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); | 995 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); |
| 996 |
| 997 value_obj = v8::Integer::New(value, isolate); |
| 998 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); |
| 988 } | 999 } |
| 989 } | 1000 } |
| 990 | 1001 |
| 991 | 1002 |
| 992 THREADED_TEST(BigInteger) { | 1003 THREADED_TEST(BigInteger) { |
| 993 v8::HandleScope scope; | 1004 v8::HandleScope scope; |
| 994 LocalContext env; | 1005 LocalContext env; |
| 1006 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 1007 |
| 995 // We cannot add one to a Smi::kMaxValue without wrapping. | 1008 // We cannot add one to a Smi::kMaxValue without wrapping. |
| 996 if (i::kSmiValueSize < 32) { | 1009 if (i::kSmiValueSize < 32) { |
| 997 // The casts allow this to compile, even if Smi::kMaxValue is 2^31-1. | 1010 // The casts allow this to compile, even if Smi::kMaxValue is 2^31-1. |
| 998 // The code will not be run in that case, due to the "if" guard. | 1011 // The code will not be run in that case, due to the "if" guard. |
| 999 int32_t value = | 1012 int32_t value = |
| 1000 static_cast<int32_t>(static_cast<uint32_t>(i::Smi::kMaxValue) + 1); | 1013 static_cast<int32_t>(static_cast<uint32_t>(i::Smi::kMaxValue) + 1); |
| 1001 CHECK(value > i::Smi::kMaxValue); | 1014 CHECK(value > i::Smi::kMaxValue); |
| 1002 CHECK(!i::Smi::IsValid(value)); | 1015 CHECK(!i::Smi::IsValid(value)); |
| 1016 |
| 1003 Local<v8::Integer> value_obj = v8::Integer::New(value); | 1017 Local<v8::Integer> value_obj = v8::Integer::New(value); |
| 1004 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); | 1018 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); |
| 1019 |
| 1020 value_obj = v8::Integer::New(value, isolate); |
| 1021 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); |
| 1005 } | 1022 } |
| 1006 } | 1023 } |
| 1007 | 1024 |
| 1008 | 1025 |
| 1009 THREADED_TEST(TinyUnsignedInteger) { | 1026 THREADED_TEST(TinyUnsignedInteger) { |
| 1010 v8::HandleScope scope; | 1027 v8::HandleScope scope; |
| 1011 LocalContext env; | 1028 LocalContext env; |
| 1029 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 1030 |
| 1012 uint32_t value = 239; | 1031 uint32_t value = 239; |
| 1032 |
| 1013 Local<v8::Integer> value_obj = v8::Integer::NewFromUnsigned(value); | 1033 Local<v8::Integer> value_obj = v8::Integer::NewFromUnsigned(value); |
| 1014 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); | 1034 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); |
| 1035 |
| 1036 value_obj = v8::Integer::NewFromUnsigned(value, isolate); |
| 1037 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); |
| 1015 } | 1038 } |
| 1016 | 1039 |
| 1017 | 1040 |
| 1018 THREADED_TEST(BigUnsignedSmiInteger) { | 1041 THREADED_TEST(BigUnsignedSmiInteger) { |
| 1019 v8::HandleScope scope; | 1042 v8::HandleScope scope; |
| 1020 LocalContext env; | 1043 LocalContext env; |
| 1044 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 1045 |
| 1021 uint32_t value = static_cast<uint32_t>(i::Smi::kMaxValue); | 1046 uint32_t value = static_cast<uint32_t>(i::Smi::kMaxValue); |
| 1022 CHECK(i::Smi::IsValid(value)); | 1047 CHECK(i::Smi::IsValid(value)); |
| 1023 CHECK(!i::Smi::IsValid(value + 1)); | 1048 CHECK(!i::Smi::IsValid(value + 1)); |
| 1049 |
| 1024 Local<v8::Integer> value_obj = v8::Integer::NewFromUnsigned(value); | 1050 Local<v8::Integer> value_obj = v8::Integer::NewFromUnsigned(value); |
| 1025 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); | 1051 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); |
| 1052 |
| 1053 value_obj = v8::Integer::NewFromUnsigned(value, isolate); |
| 1054 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); |
| 1026 } | 1055 } |
| 1027 | 1056 |
| 1028 | 1057 |
| 1029 THREADED_TEST(BigUnsignedInteger) { | 1058 THREADED_TEST(BigUnsignedInteger) { |
| 1030 v8::HandleScope scope; | 1059 v8::HandleScope scope; |
| 1031 LocalContext env; | 1060 LocalContext env; |
| 1061 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 1062 |
| 1032 uint32_t value = static_cast<uint32_t>(i::Smi::kMaxValue) + 1; | 1063 uint32_t value = static_cast<uint32_t>(i::Smi::kMaxValue) + 1; |
| 1033 CHECK(value > static_cast<uint32_t>(i::Smi::kMaxValue)); | 1064 CHECK(value > static_cast<uint32_t>(i::Smi::kMaxValue)); |
| 1034 CHECK(!i::Smi::IsValid(value)); | 1065 CHECK(!i::Smi::IsValid(value)); |
| 1066 |
| 1035 Local<v8::Integer> value_obj = v8::Integer::NewFromUnsigned(value); | 1067 Local<v8::Integer> value_obj = v8::Integer::NewFromUnsigned(value); |
| 1036 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); | 1068 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); |
| 1069 |
| 1070 value_obj = v8::Integer::NewFromUnsigned(value, isolate); |
| 1071 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); |
| 1037 } | 1072 } |
| 1038 | 1073 |
| 1039 | 1074 |
| 1040 THREADED_TEST(OutOfSignedRangeUnsignedInteger) { | 1075 THREADED_TEST(OutOfSignedRangeUnsignedInteger) { |
| 1041 v8::HandleScope scope; | 1076 v8::HandleScope scope; |
| 1042 LocalContext env; | 1077 LocalContext env; |
| 1078 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 1079 |
| 1043 uint32_t INT32_MAX_AS_UINT = (1U << 31) - 1; | 1080 uint32_t INT32_MAX_AS_UINT = (1U << 31) - 1; |
| 1044 uint32_t value = INT32_MAX_AS_UINT + 1; | 1081 uint32_t value = INT32_MAX_AS_UINT + 1; |
| 1045 CHECK(value > INT32_MAX_AS_UINT); // No overflow. | 1082 CHECK(value > INT32_MAX_AS_UINT); // No overflow. |
| 1083 |
| 1046 Local<v8::Integer> value_obj = v8::Integer::NewFromUnsigned(value); | 1084 Local<v8::Integer> value_obj = v8::Integer::NewFromUnsigned(value); |
| 1047 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); | 1085 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); |
| 1086 |
| 1087 value_obj = v8::Integer::NewFromUnsigned(value, isolate); |
| 1088 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); |
| 1048 } | 1089 } |
| 1049 | 1090 |
| 1050 | 1091 |
| 1051 THREADED_TEST(IsNativeError) { | 1092 THREADED_TEST(IsNativeError) { |
| 1052 v8::HandleScope scope; | 1093 v8::HandleScope scope; |
| 1053 LocalContext env; | 1094 LocalContext env; |
| 1054 v8::Handle<Value> syntax_error = CompileRun( | 1095 v8::Handle<Value> syntax_error = CompileRun( |
| 1055 "var out = 0; try { eval(\"#\"); } catch(x) { out = x; } out; "); | 1096 "var out = 0; try { eval(\"#\"); } catch(x) { out = x; } out; "); |
| 1056 CHECK(syntax_error->IsNativeError()); | 1097 CHECK(syntax_error->IsNativeError()); |
| 1057 v8::Handle<Value> not_error = CompileRun("{a:42}"); | 1098 v8::Handle<Value> not_error = CompileRun("{a:42}"); |
| (...skipping 16565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 17623 | 17664 |
| 17624 i::Semaphore* sem_; | 17665 i::Semaphore* sem_; |
| 17625 volatile int sem_value_; | 17666 volatile int sem_value_; |
| 17626 }; | 17667 }; |
| 17627 | 17668 |
| 17628 | 17669 |
| 17629 THREADED_TEST(SemaphoreInterruption) { | 17670 THREADED_TEST(SemaphoreInterruption) { |
| 17630 ThreadInterruptTest().RunTest(); | 17671 ThreadInterruptTest().RunTest(); |
| 17631 } | 17672 } |
| 17632 #endif // WIN32 | 17673 #endif // WIN32 |
| OLD | NEW |