| 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 2284 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  2295     "super: 6", |  2295     "super: 6", | 
|  2296     "eval: 7", |  2296     "eval: 7", | 
|  2297     "arguments: 8", |  2297     "arguments: 8", | 
|  2298     NULL |  2298     NULL | 
|  2299   }; |  2299   }; | 
|  2300  |  2300  | 
|  2301   RunParserSyncTest(context_data, statement_data, kSuccess); |  2301   RunParserSyncTest(context_data, statement_data, kSuccess); | 
|  2302 } |  2302 } | 
|  2303  |  2303  | 
|  2304  |  2304  | 
 |  2305 TEST(ObjectLiteralComputedNames) { | 
 |  2306   const char* context_data[][2] = { | 
 |  2307     {"var myobj = {", "};"}, | 
 |  2308     {"\"use strict\"; var myobj = {", "};"}, | 
 |  2309     { NULL, NULL } | 
 |  2310   }; | 
 |  2311  | 
 |  2312   const char* good_data[] = { | 
 |  2313     "['foo']: 42", | 
 |  2314     "['foo']: 42, foo: 10", | 
 |  2315     "foo: 10, ['foo']: 42", | 
 |  2316     "foo: 10, ['foo']: 42, bar: 35", | 
 |  2317     "foo: 10, bar: 35, ['foo']: 42", | 
 |  2318     "bar: 35, foo: 10, ['foo']: 42", | 
 |  2319     "bar: 35, ['foo']: 42, foo: 10", | 
 |  2320     "['bar']: 35, ['foo']: 42, foo: 10", | 
 |  2321     "['bar']: 35, foo: 10, ['foo']: 42", | 
 |  2322     "foo: 10, [1 ? 'foo' : 'bar']: 42", | 
 |  2323     "foo: 10, [0 ? 'foo' : 'bar']: 42", | 
 |  2324     "[sym]: 'ohai'", | 
 |  2325     "[1 ? sym : 'foo']: 'ohai'", | 
 |  2326     "[0 ? sym : 'foo']: 'ohai'", | 
 |  2327     "['foo']: 10, get foo() { return 42 }", | 
 |  2328     "get foo() { return 42 }, ['foo']: 10", | 
 |  2329     "0: 42, [0]: 10", | 
 |  2330     "[0]: 42, 0: 10", | 
 |  2331     NULL | 
 |  2332   }; | 
 |  2333  | 
 |  2334   const char* bad_data[] = { | 
 |  2335     "['foo", | 
 |  2336     "'foo']", | 
 |  2337     "['foo': 32]", | 
 |  2338     "['foo': 32]: 100", | 
 |  2339  | 
 |  2340     "['foo']", | 
 |  2341     "3, ['foo']", | 
 |  2342     "['foo'], 3", | 
 |  2343     "bar: baz, ['foo']", | 
 |  2344     "['foo'], bar: baz", | 
 |  2345  | 
 |  2346     // These are correct but currently unsupported. | 
 |  2347     "get ['foo']() {}", | 
 |  2348     "set ['foo']() {}", | 
 |  2349     "foo: 32, get ['foo']() {}, set ['foo'](x) {}", | 
 |  2350     NULL | 
 |  2351   }; | 
 |  2352  | 
 |  2353   bool saved_flag = i::FLAG_harmony_object_literals; | 
 |  2354   i::FLAG_harmony_object_literals = true; | 
 |  2355  | 
 |  2356   RunParserSyncTest(context_data, good_data, kSuccess); | 
 |  2357   RunParserSyncTest(context_data, bad_data, kError); | 
 |  2358  | 
 |  2359   i::FLAG_harmony_object_literals = saved_flag; | 
 |  2360 } | 
 |  2361  | 
 |  2362  | 
|  2305 TEST(TooManyArguments) { |  2363 TEST(TooManyArguments) { | 
|  2306   const char* context_data[][2] = { |  2364   const char* context_data[][2] = { | 
|  2307     {"foo(", "0)"}, |  2365     {"foo(", "0)"}, | 
|  2308     { NULL, NULL } |  2366     { NULL, NULL } | 
|  2309   }; |  2367   }; | 
|  2310  |  2368  | 
|  2311   using v8::internal::Code; |  2369   using v8::internal::Code; | 
|  2312   char statement[Code::kMaxArguments * 2 + 1]; |  2370   char statement[Code::kMaxArguments * 2 + 1]; | 
|  2313   for (int i = 0; i < Code::kMaxArguments; ++i) { |  2371   for (int i = 0; i < Code::kMaxArguments; ++i) { | 
|  2314     statement[2 * i] = '0'; |  2372     statement[2 * i] = '0'; | 
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  2540   v8::Local<v8::String> source = |  2598   v8::Local<v8::String> source = | 
|  2541       v8::String::NewFromTwoByte(isolate, two_byte_source); |  2599       v8::String::NewFromTwoByte(isolate, two_byte_source); | 
|  2542   v8::Local<v8::Value> result = CompileRun(source); |  2600   v8::Local<v8::Value> result = CompileRun(source); | 
|  2543   CHECK(result->IsString()); |  2601   CHECK(result->IsString()); | 
|  2544   v8::Local<v8::String> expected_name = |  2602   v8::Local<v8::String> expected_name = | 
|  2545       v8::String::NewFromTwoByte(isolate, two_byte_name); |  2603       v8::String::NewFromTwoByte(isolate, two_byte_name); | 
|  2546   CHECK(result->Equals(expected_name)); |  2604   CHECK(result->Equals(expected_name)); | 
|  2547   i::DeleteArray(two_byte_source); |  2605   i::DeleteArray(two_byte_source); | 
|  2548   i::DeleteArray(two_byte_name); |  2606   i::DeleteArray(two_byte_name); | 
|  2549 } |  2607 } | 
| OLD | NEW |