| 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 999 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1010 " (non_ascii[j] + external_non_ascii[i - j])) return 12;" | 1010 " (non_ascii[j] + external_non_ascii[i - j])) return 12;" |
| 1011 " }" | 1011 " }" |
| 1012 " }" | 1012 " }" |
| 1013 " return 0;" | 1013 " return 0;" |
| 1014 "};" | 1014 "};" |
| 1015 "test()"; | 1015 "test()"; |
| 1016 CHECK_EQ(0, CompileRun(source)->Int32Value()); | 1016 CHECK_EQ(0, CompileRun(source)->Int32Value()); |
| 1017 } | 1017 } |
| 1018 | 1018 |
| 1019 | 1019 |
| 1020 TEST(JSONStringifySliceMadeExternal) { | |
| 1021 Isolate* isolate = Isolate::Current(); | |
| 1022 Zone zone(isolate); | |
| 1023 CcTest::InitializeVM(); | |
| 1024 // Create a sliced string from a one-byte string. The latter is turned | |
| 1025 // into a two-byte external string. Check that JSON.stringify works. | |
| 1026 v8::HandleScope handle_scope(CcTest::isolate()); | |
| 1027 v8::Handle<v8::String> underlying = | |
| 1028 CompileRun("var underlying = 'abcdefghijklmnopqrstuvwxyz';" | |
| 1029 "underlying")->ToString(); | |
| 1030 v8::Handle<v8::String> slice = | |
| 1031 CompileRun("var slice = underlying.slice(1);" | |
| 1032 "slice")->ToString(); | |
| 1033 CHECK(v8::Utils::OpenHandle(*slice)->IsSlicedString()); | |
| 1034 CHECK(v8::Utils::OpenHandle(*underlying)->IsSeqOneByteString()); | |
| 1035 | |
| 1036 int length = underlying->Length(); | |
| 1037 uc16* two_byte = zone.NewArray<uc16>(length + 1); | |
| 1038 underlying->Write(two_byte); | |
| 1039 Resource* resource = | |
| 1040 new(&zone) Resource(Vector<const uc16>(two_byte, length)); | |
| 1041 CHECK(underlying->MakeExternal(resource)); | |
| 1042 CHECK(v8::Utils::OpenHandle(*slice)->IsSlicedString()); | |
| 1043 CHECK(v8::Utils::OpenHandle(*underlying)->IsExternalTwoByteString()); | |
| 1044 | |
| 1045 CHECK_EQ("\"bcdefghijklmnopqrstuvwxyz\"", | |
| 1046 *v8::String::Utf8Value(CompileRun("JSON.stringify(slice)"))); | |
| 1047 } | |
| 1048 | |
| 1049 | |
| 1050 TEST(CachedHashOverflow) { | 1020 TEST(CachedHashOverflow) { |
| 1051 // We incorrectly allowed strings to be tagged as array indices even if their | 1021 // We incorrectly allowed strings to be tagged as array indices even if their |
| 1052 // values didn't fit in the hash field. | 1022 // values didn't fit in the hash field. |
| 1053 // See http://code.google.com/p/v8/issues/detail?id=728 | 1023 // See http://code.google.com/p/v8/issues/detail?id=728 |
| 1054 Isolate* isolate = Isolate::Current(); | 1024 Isolate* isolate = Isolate::Current(); |
| 1055 Zone zone(isolate); | 1025 Zone zone(isolate); |
| 1056 | 1026 |
| 1057 CcTest::InitializeVM(); | 1027 CcTest::InitializeVM(); |
| 1058 v8::HandleScope handle_scope(CcTest::isolate()); | 1028 v8::HandleScope handle_scope(CcTest::isolate()); |
| 1059 // Lines must be executed sequentially. Combining them into one script | 1029 // Lines must be executed sequentially. Combining them into one script |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1379 CheckCanonicalEquivalence(c, test); | 1349 CheckCanonicalEquivalence(c, test); |
| 1380 continue; | 1350 continue; |
| 1381 } | 1351 } |
| 1382 if (upper != c && lower != c) { | 1352 if (upper != c && lower != c) { |
| 1383 CheckCanonicalEquivalence(c, test); | 1353 CheckCanonicalEquivalence(c, test); |
| 1384 continue; | 1354 continue; |
| 1385 } | 1355 } |
| 1386 CHECK_EQ(Min(upper, lower), test); | 1356 CHECK_EQ(Min(upper, lower), test); |
| 1387 } | 1357 } |
| 1388 } | 1358 } |
| OLD | NEW |