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 5752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5763 int len) { | 5763 int len) { |
5764 Local<v8::Array> a = | 5764 Local<v8::Array> a = |
5765 Local<v8::Array>::Cast(context->Global()->Get(v8_str(name))); | 5765 Local<v8::Array>::Cast(context->Global()->Get(v8_str(name))); |
5766 Local<v8::Array> alens = | 5766 Local<v8::Array> alens = |
5767 Local<v8::Array>::Cast(context->Global()->Get(v8_str(lengths_name))); | 5767 Local<v8::Array>::Cast(context->Global()->Get(v8_str(lengths_name))); |
5768 for (int i = 0; i < len; i++) { | 5768 for (int i = 0; i < len; i++) { |
5769 Local<v8::String> string = | 5769 Local<v8::String> string = |
5770 Local<v8::String>::Cast(a->Get(i)); | 5770 Local<v8::String>::Cast(a->Get(i)); |
5771 Local<v8::Number> expected_len = | 5771 Local<v8::Number> expected_len = |
5772 Local<v8::Number>::Cast(alens->Get(i)); | 5772 Local<v8::Number>::Cast(alens->Get(i)); |
5773 CHECK_EQ((expected_len->Value() != string->Length()), | |
5774 string->MayContainNonAscii()); | |
fschneider
2012/03/19 08:46:31
Fix indentation here.
Erik Corry
2012/03/19 09:51:02
Done.
| |
5773 int length = GetUtf8Length(string); | 5775 int length = GetUtf8Length(string); |
5774 CHECK_EQ(static_cast<int>(expected_len->Value()), length); | 5776 CHECK_EQ(static_cast<int>(expected_len->Value()), length); |
5775 } | 5777 } |
5776 } | 5778 } |
5777 | 5779 |
5778 | 5780 |
5779 static uint16_t StringGet(Handle<String> str, int index) { | 5781 static uint16_t StringGet(Handle<String> str, int index) { |
5780 i::Handle<i::String> istring = | 5782 i::Handle<i::String> istring = |
5781 v8::Utils::OpenHandle(String::Cast(*str)); | 5783 v8::Utils::OpenHandle(String::Cast(*str)); |
5782 return istring->Get(index); | 5784 return istring->Get(index); |
(...skipping 6137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
11920 FACTORY->NewExternalStringFromAscii(&ascii_resource))); | 11922 FACTORY->NewExternalStringFromAscii(&ascii_resource))); |
11921 | 11923 |
11922 env->Global()->Set(v8_str("lhs"), lhs); | 11924 env->Global()->Set(v8_str("lhs"), lhs); |
11923 env->Global()->Set(v8_str("rhs"), rhs); | 11925 env->Global()->Set(v8_str("rhs"), rhs); |
11924 | 11926 |
11925 CompileRun( | 11927 CompileRun( |
11926 "var cons = lhs + rhs;" | 11928 "var cons = lhs + rhs;" |
11927 "var slice = lhs.substring(1, lhs.length - 1);" | 11929 "var slice = lhs.substring(1, lhs.length - 1);" |
11928 "var slice_on_cons = (lhs + rhs).substring(1, lhs.length *2 - 1);"); | 11930 "var slice_on_cons = (lhs + rhs).substring(1, lhs.length *2 - 1);"); |
11929 | 11931 |
11932 CHECK(!lhs->MayContainNonAscii()); | |
11933 CHECK(!rhs->MayContainNonAscii()); | |
11934 | |
11930 MorphAString(*v8::Utils::OpenHandle(*lhs), &ascii_resource, &uc16_resource); | 11935 MorphAString(*v8::Utils::OpenHandle(*lhs), &ascii_resource, &uc16_resource); |
11931 MorphAString(*v8::Utils::OpenHandle(*rhs), &ascii_resource, &uc16_resource); | 11936 MorphAString(*v8::Utils::OpenHandle(*rhs), &ascii_resource, &uc16_resource); |
11932 | 11937 |
11933 // This should UTF-8 without flattening, since everything is ASCII. | 11938 // This should UTF-8 without flattening, since everything is ASCII. |
11934 Handle<String> cons = v8_compile("cons")->Run().As<String>(); | 11939 Handle<String> cons = v8_compile("cons")->Run().As<String>(); |
11935 CHECK_EQ(128, cons->Utf8Length()); | 11940 CHECK_EQ(128, cons->Utf8Length()); |
11936 int nchars = -1; | 11941 int nchars = -1; |
11937 CHECK_EQ(129, cons->WriteUtf8(utf_buffer, -1, &nchars)); | 11942 CHECK_EQ(129, cons->WriteUtf8(utf_buffer, -1, &nchars)); |
11938 CHECK_EQ(128, nchars); | 11943 CHECK_EQ(128, nchars); |
11939 CHECK_EQ(0, strcmp( | 11944 CHECK_EQ(0, strcmp( |
(...skipping 4443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
16383 | 16388 |
16384 TEST(SecondaryStubCache) { | 16389 TEST(SecondaryStubCache) { |
16385 StubCacheHelper(true); | 16390 StubCacheHelper(true); |
16386 } | 16391 } |
16387 | 16392 |
16388 | 16393 |
16389 TEST(PrimaryStubCache) { | 16394 TEST(PrimaryStubCache) { |
16390 StubCacheHelper(false); | 16395 StubCacheHelper(false); |
16391 } | 16396 } |
16392 | 16397 |
OLD | NEW |