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 21966 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
21977 "bar2.js"); | 21977 "bar2.js"); |
21978 } | 21978 } |
21979 | 21979 |
21980 | 21980 |
21981 TEST(StreamingScriptWithSourceMappingURLInTheMiddle) { | 21981 TEST(StreamingScriptWithSourceMappingURLInTheMiddle) { |
21982 const char* chunks[] = {"function foo() { ret", "urn 13; }\n//#", | 21982 const char* chunks[] = {"function foo() { ret", "urn 13; }\n//#", |
21983 " sourceMappingURL=bar2.js\n", "foo();", NULL}; | 21983 " sourceMappingURL=bar2.js\n", "foo();", NULL}; |
21984 RunStreamingTest(chunks, v8::ScriptCompiler::StreamedSource::UTF8, true, NULL, | 21984 RunStreamingTest(chunks, v8::ScriptCompiler::StreamedSource::UTF8, true, NULL, |
21985 "bar2.js"); | 21985 "bar2.js"); |
21986 } | 21986 } |
| 21987 |
| 21988 |
| 21989 TEST(NewStringRangeError) { |
| 21990 v8::Isolate* isolate = CcTest::isolate(); |
| 21991 v8::HandleScope handle_scope(isolate); |
| 21992 LocalContext env; |
| 21993 const int length = i::String::kMaxLength + 1; |
| 21994 const int buffer_size = length * sizeof(uint16_t); |
| 21995 void* buffer = malloc(buffer_size); |
| 21996 memset(buffer, 'A', buffer_size); |
| 21997 { |
| 21998 v8::TryCatch try_catch; |
| 21999 char* data = reinterpret_cast<char*>(buffer); |
| 22000 CHECK(v8::String::NewFromUtf8(isolate, data, v8::String::kNormalString, |
| 22001 length).IsEmpty()); |
| 22002 CHECK(try_catch.HasCaught()); |
| 22003 } |
| 22004 { |
| 22005 v8::TryCatch try_catch; |
| 22006 uint8_t* data = reinterpret_cast<uint8_t*>(buffer); |
| 22007 CHECK(v8::String::NewFromOneByte(isolate, data, v8::String::kNormalString, |
| 22008 length).IsEmpty()); |
| 22009 CHECK(try_catch.HasCaught()); |
| 22010 } |
| 22011 { |
| 22012 v8::TryCatch try_catch; |
| 22013 uint16_t* data = reinterpret_cast<uint16_t*>(buffer); |
| 22014 CHECK(v8::String::NewFromTwoByte(isolate, data, v8::String::kNormalString, |
| 22015 length).IsEmpty()); |
| 22016 CHECK(try_catch.HasCaught()); |
| 22017 } |
| 22018 } |
OLD | NEW |