OLD | NEW |
---|---|
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 2030 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2041 CHECK_EQ(32, context->Global()->Get(v8_num(16))->Int32Value()); | 2041 CHECK_EQ(32, context->Global()->Get(v8_num(16))->Int32Value()); |
2042 CHECK_EQ(56, context->Global()->Get(v8::Integer::New(13))->Int32Value()); | 2042 CHECK_EQ(56, context->Global()->Get(v8::Integer::New(13))->Int32Value()); |
2043 CHECK_EQ(56, context->Global()->Get(v8_str("13"))->Int32Value()); | 2043 CHECK_EQ(56, context->Global()->Get(v8_str("13"))->Int32Value()); |
2044 CHECK_EQ(56, context->Global()->Get(v8_num(13))->Int32Value()); | 2044 CHECK_EQ(56, context->Global()->Get(v8_num(13))->Int32Value()); |
2045 } | 2045 } |
2046 | 2046 |
2047 | 2047 |
2048 THREADED_TEST(PropertyAttributes) { | 2048 THREADED_TEST(PropertyAttributes) { |
2049 v8::HandleScope scope; | 2049 v8::HandleScope scope; |
2050 LocalContext context; | 2050 LocalContext context; |
2051 // none | |
2052 Local<String> prop = v8_str("none"); | |
2053 context->Global()->Set(prop, v8_num(7)); | |
2054 CHECK_EQ(v8::None, context->Global()->GetPropertyAttribute(prop)); | |
2051 // read-only | 2055 // read-only |
2052 Local<String> prop = v8_str("read_only"); | 2056 prop = v8_str("read_only"); |
2053 context->Global()->Set(prop, v8_num(7), v8::ReadOnly); | 2057 context->Global()->Set(prop, v8_num(7), v8::ReadOnly); |
2054 CHECK_EQ(7, context->Global()->Get(prop)->Int32Value()); | 2058 CHECK_EQ(7, context->Global()->Get(prop)->Int32Value()); |
2059 CHECK_EQ(v8::ReadOnly, context->Global()->GetPropertyAttribute(prop)); | |
2055 Script::Compile(v8_str("read_only = 9"))->Run(); | 2060 Script::Compile(v8_str("read_only = 9"))->Run(); |
2056 CHECK_EQ(7, context->Global()->Get(prop)->Int32Value()); | 2061 CHECK_EQ(7, context->Global()->Get(prop)->Int32Value()); |
2057 context->Global()->Set(prop, v8_num(10)); | 2062 context->Global()->Set(prop, v8_num(10)); |
2058 CHECK_EQ(7, context->Global()->Get(prop)->Int32Value()); | 2063 CHECK_EQ(7, context->Global()->Get(prop)->Int32Value()); |
2059 // dont-delete | 2064 // dont-delete |
2060 prop = v8_str("dont_delete"); | 2065 prop = v8_str("dont_delete"); |
2061 context->Global()->Set(prop, v8_num(13), v8::DontDelete); | 2066 context->Global()->Set(prop, v8_num(13), v8::DontDelete); |
2062 CHECK_EQ(13, context->Global()->Get(prop)->Int32Value()); | 2067 CHECK_EQ(13, context->Global()->Get(prop)->Int32Value()); |
2063 Script::Compile(v8_str("delete dont_delete"))->Run(); | 2068 Script::Compile(v8_str("delete dont_delete"))->Run(); |
2064 CHECK_EQ(13, context->Global()->Get(prop)->Int32Value()); | 2069 CHECK_EQ(13, context->Global()->Get(prop)->Int32Value()); |
2070 CHECK_EQ(v8::DontDelete, context->Global()->GetPropertyAttribute(prop)); | |
2071 // dont-enum | |
2072 prop = v8_str("dont_enum"); | |
2073 context->Global()->Set(prop, v8_num(28), v8::DontEnum); | |
2074 CHECK_EQ(v8::DontEnum, context->Global()->GetPropertyAttribute(prop)); | |
2075 // absent | |
2076 TryCatch try_catch; | |
2077 prop = v8_str("absent"); | |
2078 CHECK_EQ(v8::None, context->Global()->GetPropertyAttribute(prop)); | |
2079 CHECK(try_catch.HasCaught()); | |
2080 String::AsciiValue exception_value1(try_catch.Exception()); | |
2081 CHECK_EQ("ReferenceError: absent is not defined", *exception_value1); | |
2082 try_catch.Reset(); | |
2083 Local<Value> fake_prop = v8_num(1); | |
2084 CHECK_EQ(v8::None, context->Global()->GetPropertyAttribute(fake_prop)); | |
2085 CHECK(try_catch.HasCaught()); | |
2086 String::AsciiValue exception_value2(try_catch.Exception()); | |
2087 CHECK_EQ("ReferenceError: 1 is not defined", *exception_value2); | |
2088 try_catch.Reset(); | |
Mads Ager (chromium)
2011/07/15 07:25:51
You should add a test where the string conversion
| |
2065 } | 2089 } |
2066 | 2090 |
2067 | 2091 |
2068 THREADED_TEST(Array) { | 2092 THREADED_TEST(Array) { |
2069 v8::HandleScope scope; | 2093 v8::HandleScope scope; |
2070 LocalContext context; | 2094 LocalContext context; |
2071 Local<v8::Array> array = v8::Array::New(); | 2095 Local<v8::Array> array = v8::Array::New(); |
2072 CHECK_EQ(0, array->Length()); | 2096 CHECK_EQ(0, array->Length()); |
2073 CHECK(array->Get(0)->IsUndefined()); | 2097 CHECK(array->Get(0)->IsUndefined()); |
2074 CHECK(!array->Has(0)); | 2098 CHECK(!array->Has(0)); |
(...skipping 12604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
14679 } | 14703 } |
14680 | 14704 |
14681 i::Isolate::Current()->heap()->CollectAllGarbage(true); | 14705 i::Isolate::Current()->heap()->CollectAllGarbage(true); |
14682 { i::Object* raw_map_cache = i::Isolate::Current()->context()->map_cache(); | 14706 { i::Object* raw_map_cache = i::Isolate::Current()->context()->map_cache(); |
14683 if (raw_map_cache != i::Isolate::Current()->heap()->undefined_value()) { | 14707 if (raw_map_cache != i::Isolate::Current()->heap()->undefined_value()) { |
14684 i::MapCache* map_cache = i::MapCache::cast(raw_map_cache); | 14708 i::MapCache* map_cache = i::MapCache::cast(raw_map_cache); |
14685 CHECK_GT(elements, map_cache->NumberOfElements()); | 14709 CHECK_GT(elements, map_cache->NumberOfElements()); |
14686 } | 14710 } |
14687 } | 14711 } |
14688 } | 14712 } |
OLD | NEW |