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 21896 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
21907 "bar2.js"); | 21907 "bar2.js"); |
21908 } | 21908 } |
21909 | 21909 |
21910 | 21910 |
21911 TEST(StreamingScriptWithSourceMappingURLInTheMiddle) { | 21911 TEST(StreamingScriptWithSourceMappingURLInTheMiddle) { |
21912 const char* chunks[] = {"function foo() { ret", "urn 13; }\n//#", | 21912 const char* chunks[] = {"function foo() { ret", "urn 13; }\n//#", |
21913 " sourceMappingURL=bar2.js\n", "foo();", NULL}; | 21913 " sourceMappingURL=bar2.js\n", "foo();", NULL}; |
21914 RunStreamingTest(chunks, v8::ScriptCompiler::StreamedSource::UTF8, true, NULL, | 21914 RunStreamingTest(chunks, v8::ScriptCompiler::StreamedSource::UTF8, true, NULL, |
21915 "bar2.js"); | 21915 "bar2.js"); |
21916 } | 21916 } |
| 21917 |
| 21918 |
| 21919 TEST(NewStringRangeError) { |
| 21920 v8::Isolate* isolate = CcTest::isolate(); |
| 21921 v8::HandleScope handle_scope(isolate); |
| 21922 LocalContext env; |
| 21923 const int length = i::String::kMaxLength + 1; |
| 21924 const int buffer_size = length * sizeof(uint16_t); |
| 21925 void* buffer = malloc(buffer_size); |
| 21926 memset(buffer, 'A', buffer_size); |
| 21927 { |
| 21928 v8::TryCatch try_catch; |
| 21929 char* data = reinterpret_cast<char*>(buffer); |
| 21930 CHECK(v8::String::NewFromUtf8(isolate, data, v8::String::kNormalString, |
| 21931 length).IsEmpty()); |
| 21932 CHECK(try_catch.HasCaught()); |
| 21933 } |
| 21934 { |
| 21935 v8::TryCatch try_catch; |
| 21936 uint8_t* data = reinterpret_cast<uint8_t*>(buffer); |
| 21937 CHECK(v8::String::NewFromOneByte(isolate, data, v8::String::kNormalString, |
| 21938 length).IsEmpty()); |
| 21939 CHECK(try_catch.HasCaught()); |
| 21940 } |
| 21941 { |
| 21942 v8::TryCatch try_catch; |
| 21943 uint16_t* data = reinterpret_cast<uint16_t*>(buffer); |
| 21944 CHECK(v8::String::NewFromTwoByte(isolate, data, v8::String::kNormalString, |
| 21945 length).IsEmpty()); |
| 21946 CHECK(try_catch.HasCaught()); |
| 21947 } |
| 21948 free(buffer); |
| 21949 } |
OLD | NEW |