| 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 7300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7311 Local<Value> s4 = global->Get(v8_str("sym4")); | 7311 Local<Value> s4 = global->Get(v8_str("sym4")); |
| 7312 CHECK(SameSymbol(sym0, Handle<String>::Cast(s0))); | 7312 CHECK(SameSymbol(sym0, Handle<String>::Cast(s0))); |
| 7313 CHECK(SameSymbol(sym0b, Handle<String>::Cast(s0b))); | 7313 CHECK(SameSymbol(sym0b, Handle<String>::Cast(s0b))); |
| 7314 CHECK(SameSymbol(sym1, Handle<String>::Cast(s1))); | 7314 CHECK(SameSymbol(sym1, Handle<String>::Cast(s1))); |
| 7315 CHECK(SameSymbol(sym2, Handle<String>::Cast(s2))); | 7315 CHECK(SameSymbol(sym2, Handle<String>::Cast(s2))); |
| 7316 CHECK(SameSymbol(sym3, Handle<String>::Cast(s3))); | 7316 CHECK(SameSymbol(sym3, Handle<String>::Cast(s3))); |
| 7317 CHECK(SameSymbol(sym4, Handle<String>::Cast(s4))); | 7317 CHECK(SameSymbol(sym4, Handle<String>::Cast(s4))); |
| 7318 } | 7318 } |
| 7319 | 7319 |
| 7320 | 7320 |
| 7321 THREADED_TEST(Utf16MissingTrailing) { |
| 7322 LocalContext context; |
| 7323 v8::HandleScope scope(context->GetIsolate()); |
| 7324 |
| 7325 // Make sure it will go past the buffer, so it will call `WriteUtf16Slow` |
| 7326 int size = 1024 * 64; |
| 7327 uint8_t* buffer = new uint8_t[size]; |
| 7328 for (int i = 0; i < size; i += 4) { |
| 7329 buffer[i] = 0xf0; |
| 7330 buffer[i + 1] = 0x9d; |
| 7331 buffer[i + 2] = 0x80; |
| 7332 buffer[i + 3] = 0x9e; |
| 7333 } |
| 7334 |
| 7335 // Now invoke the decoder without last 3 bytes |
| 7336 v8::Local<v8::String> str = |
| 7337 v8::String::NewFromUtf8( |
| 7338 context->GetIsolate(), reinterpret_cast<char*>(buffer), |
| 7339 v8::NewStringType::kNormal, size - 3).ToLocalChecked(); |
| 7340 USE(str); |
| 7341 delete[] buffer; |
| 7342 } |
| 7343 |
| 7344 |
| 7345 THREADED_TEST(Utf16Trailing3Byte) { |
| 7346 LocalContext context; |
| 7347 v8::HandleScope scope(context->GetIsolate()); |
| 7348 |
| 7349 // Make sure it will go past the buffer, so it will call `WriteUtf16Slow` |
| 7350 int size = 1024 * 63; |
| 7351 uint8_t* buffer = new uint8_t[size]; |
| 7352 for (int i = 0; i < size; i += 3) { |
| 7353 buffer[i] = 0xe2; |
| 7354 buffer[i + 1] = 0x80; |
| 7355 buffer[i + 2] = 0xa6; |
| 7356 } |
| 7357 |
| 7358 // Now invoke the decoder without last 3 bytes |
| 7359 v8::Local<v8::String> str = |
| 7360 v8::String::NewFromUtf8( |
| 7361 context->GetIsolate(), reinterpret_cast<char*>(buffer), |
| 7362 v8::NewStringType::kNormal, size).ToLocalChecked(); |
| 7363 |
| 7364 v8::String::Value value(str); |
| 7365 CHECK_EQ(value.length(), size / 3); |
| 7366 CHECK_EQ((*value)[value.length() - 1], 0x2026); |
| 7367 |
| 7368 delete[] buffer; |
| 7369 } |
| 7370 |
| 7371 |
| 7321 THREADED_TEST(ToArrayIndex) { | 7372 THREADED_TEST(ToArrayIndex) { |
| 7322 LocalContext context; | 7373 LocalContext context; |
| 7323 v8::Isolate* isolate = context->GetIsolate(); | 7374 v8::Isolate* isolate = context->GetIsolate(); |
| 7324 v8::HandleScope scope(isolate); | 7375 v8::HandleScope scope(isolate); |
| 7325 | 7376 |
| 7326 v8::Handle<String> str = v8_str("42"); | 7377 v8::Handle<String> str = v8_str("42"); |
| 7327 v8::Handle<v8::Uint32> index = str->ToArrayIndex(); | 7378 v8::Handle<v8::Uint32> index = str->ToArrayIndex(); |
| 7328 CHECK(!index.IsEmpty()); | 7379 CHECK(!index.IsEmpty()); |
| 7329 CHECK_EQ(42.0, index->Uint32Value()); | 7380 CHECK_EQ(42.0, index->Uint32Value()); |
| 7330 str = v8_str("42asdf"); | 7381 str = v8_str("42asdf"); |
| (...skipping 13628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 20959 " fake.age;\n" | 21010 " fake.age;\n" |
| 20960 " result = 1;\n" | 21011 " result = 1;\n" |
| 20961 " } catch (e) {\n" | 21012 " } catch (e) {\n" |
| 20962 " }\n" | 21013 " }\n" |
| 20963 " test(d+1);\n" | 21014 " test(d+1);\n" |
| 20964 "}\n" | 21015 "}\n" |
| 20965 "test(0);\n" | 21016 "test(0);\n" |
| 20966 "result;\n", | 21017 "result;\n", |
| 20967 0); | 21018 0); |
| 20968 } | 21019 } |
| OLD | NEW |