| OLD | NEW |
| 1 // Copyright 2007-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2008 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 5015 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5026 } | 5026 } |
| 5027 | 5027 |
| 5028 | 5028 |
| 5029 THREADED_TEST(DateAccess) { | 5029 THREADED_TEST(DateAccess) { |
| 5030 v8::HandleScope scope; | 5030 v8::HandleScope scope; |
| 5031 LocalContext context; | 5031 LocalContext context; |
| 5032 v8::Handle<v8::Value> date = v8::Date::New(1224744689038.0); | 5032 v8::Handle<v8::Value> date = v8::Date::New(1224744689038.0); |
| 5033 CHECK(date->IsDate()); | 5033 CHECK(date->IsDate()); |
| 5034 CHECK_EQ(1224744689038.0, v8::Handle<v8::Date>::Cast(date)->NumberValue()); | 5034 CHECK_EQ(1224744689038.0, v8::Handle<v8::Date>::Cast(date)->NumberValue()); |
| 5035 } | 5035 } |
| 5036 |
| 5037 |
| 5038 void CheckProperties(v8::Handle<v8::Value> val, int elmc, const char* elmv[]) { |
| 5039 v8::Handle<v8::Object> obj = v8::Handle<v8::Object>::Cast(val); |
| 5040 v8::Handle<v8::Array> props = obj->GetProperties(); |
| 5041 CHECK_EQ(elmc, props->Length()); |
| 5042 for (int i = 0; i < elmc; i++) { |
| 5043 v8::String::Utf8Value elm(props->Get(v8::Integer::New(i))); |
| 5044 CHECK_EQ(elmv[i], *elm); |
| 5045 } |
| 5046 } |
| 5047 |
| 5048 |
| 5049 THREADED_TEST(PropertyEnumeration) { |
| 5050 v8::HandleScope scope; |
| 5051 LocalContext context; |
| 5052 v8::Handle<v8::Value> obj = v8::Script::Compile(v8::String::New( |
| 5053 "var result = [];" |
| 5054 "result[0] = {};" |
| 5055 "result[1] = {a: 1, b: 2};" |
| 5056 "result[2] = [1, 2, 3];" |
| 5057 "var proto = {x: 1, y: 2, z: 3};" |
| 5058 "var x = { __proto__: proto, w: 0, z: 1 };" |
| 5059 "result[3] = x;" |
| 5060 "result;" |
| 5061 ))->Run(); |
| 5062 v8::Handle<v8::Array> elms = v8::Handle<v8::Array>::Cast(obj); |
| 5063 CHECK_EQ(4, elms->Length()); |
| 5064 int elmc0 = 0; |
| 5065 const char** elmv0 = NULL; |
| 5066 CheckProperties(elms->Get(v8::Integer::New(0)), elmc0, elmv0); |
| 5067 int elmc1 = 2; |
| 5068 const char* elmv1[] = {"a", "b"}; |
| 5069 CheckProperties(elms->Get(v8::Integer::New(1)), elmc1, elmv1); |
| 5070 int elmc2 = 3; |
| 5071 const char* elmv2[] = {"0", "1", "2"}; |
| 5072 CheckProperties(elms->Get(v8::Integer::New(2)), elmc2, elmv2); |
| 5073 int elmc3 = 4; |
| 5074 const char* elmv3[] = {"w", "z", "x", "y"}; |
| 5075 CheckProperties(elms->Get(v8::Integer::New(3)), elmc3, elmv3); |
| 5076 } |
| OLD | NEW |