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 23922 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
23933 CHECK_EQ(13, result->Int32Value(env.local()).FromJust()); | 23933 CHECK_EQ(13, result->Int32Value(env.local()).FromJust()); |
23934 CheckMagicComments(script.ToLocalChecked(), expected_source_url, | 23934 CheckMagicComments(script.ToLocalChecked(), expected_source_url, |
23935 expected_source_mapping_url); | 23935 expected_source_mapping_url); |
23936 } else { | 23936 } else { |
23937 CHECK(script.IsEmpty()); | 23937 CHECK(script.IsEmpty()); |
23938 CHECK(try_catch.HasCaught()); | 23938 CHECK(try_catch.HasCaught()); |
23939 } | 23939 } |
23940 delete[] full_source; | 23940 delete[] full_source; |
23941 } | 23941 } |
23942 | 23942 |
23943 | |
23944 TEST(StreamingSimpleScript) { | 23943 TEST(StreamingSimpleScript) { |
23945 // This script is unrealistically small, since no one chunk is enough to fill | 23944 // This script is unrealistically small, since no one chunk is enough to fill |
23946 // the backing buffer of Scanner, let alone overflow it. | 23945 // the backing buffer of Scanner, let alone overflow it. |
23947 const char* chunks[] = {"function foo() { ret", "urn 13; } f", "oo(); ", | 23946 const char* chunks[] = {"function foo() { ret", "urn 13; } f", "oo(); ", |
23948 NULL}; | 23947 NULL}; |
23949 RunStreamingTest(chunks); | 23948 RunStreamingTest(chunks); |
23950 } | 23949 } |
23951 | 23950 |
| 23951 TEST(StreamingScriptConstantArray) { |
| 23952 // When run with Ignition, tests that the streaming parser canonicalizes |
| 23953 // handles so that they are only added to the constant pool array once. |
| 23954 const char* chunks[] = {"var a = {};", |
| 23955 "var b = {};", |
| 23956 "var c = 'testing';", |
| 23957 "var d = 'testing';", |
| 23958 "13;", |
| 23959 NULL}; |
| 23960 RunStreamingTest(chunks); |
| 23961 } |
23952 | 23962 |
23953 TEST(StreamingBiggerScript) { | 23963 TEST(StreamingBiggerScript) { |
23954 const char* chunk1 = | 23964 const char* chunk1 = |
23955 "function foo() {\n" | 23965 "function foo() {\n" |
23956 " // Make this chunk sufficiently long so that it will overflow the\n" | 23966 " // Make this chunk sufficiently long so that it will overflow the\n" |
23957 " // backing buffer of the Scanner.\n" | 23967 " // backing buffer of the Scanner.\n" |
23958 " var i = 0;\n" | 23968 " var i = 0;\n" |
23959 " var result = 0;\n" | 23969 " var result = 0;\n" |
23960 " for (i = 0; i < 13; ++i) { result = result + 1; }\n" | 23970 " for (i = 0; i < 13; ++i) { result = result + 1; }\n" |
23961 " result = 0;\n" | 23971 " result = 0;\n" |
(...skipping 1534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
25496 | 25506 |
25497 // Put the function into context1 and call it. Since the access check | 25507 // Put the function into context1 and call it. Since the access check |
25498 // callback always returns true, the call succeeds even though the tokens | 25508 // callback always returns true, the call succeeds even though the tokens |
25499 // are different. | 25509 // are different. |
25500 context1->Enter(); | 25510 context1->Enter(); |
25501 context1->Global()->Set(context1, v8_str("fun"), fun).FromJust(); | 25511 context1->Global()->Set(context1, v8_str("fun"), fun).FromJust(); |
25502 v8::Local<v8::Value> x_value = CompileRun("fun('x')"); | 25512 v8::Local<v8::Value> x_value = CompileRun("fun('x')"); |
25503 CHECK_EQ(42, x_value->Int32Value(context1).FromJust()); | 25513 CHECK_EQ(42, x_value->Int32Value(context1).FromJust()); |
25504 context1->Exit(); | 25514 context1->Exit(); |
25505 } | 25515 } |
OLD | NEW |