diff options
author | Philip Lorenz <philip@bithub.de> | 2012-09-11 17:55:08 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-09-24 10:14:18 +0200 |
commit | 23ec442d83b5935fbb8af4d34026d58b7734fe12 (patch) | |
tree | ee7af7566cf05191a0414c3f6a765a590fc66dea /tests | |
parent | a7cbe3715872fc122173603d5c639aa0adb148be (diff) | |
download | qtjsbackend-23ec442d83b5935fbb8af4d34026d58b7734fe12.tar.gz |
Always initialise symbol_id for ASCII symbols
Commit 30662b5d64ff633f57d89290da2a85507d561187 dropped the default
initialisation of the symbol_id for ASCII characters. This leads to
problems when trying to access the symbol_id when the symbol was not
instantiated via AsciiSymbolKey (e.g. via SubStringAsciiSymbolKey).
Additionally, AsciiSymbolKey does not guarantee the presence of a
symbol_id in case the SMI value space has been exhausted.
Change-Id: I778bc5cc3cee80038a4ca6606bfcf4423d569132
Reviewed-by: Peter Varga <pvarga@inf.u-szeged.hu>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/v8/tst_v8.cpp | 6 | ||||
-rw-r--r-- | tests/auto/v8/v8test.cpp | 48 | ||||
-rw-r--r-- | tests/auto/v8/v8test.h | 1 |
3 files changed, 55 insertions, 0 deletions
diff --git a/tests/auto/v8/tst_v8.cpp b/tests/auto/v8/tst_v8.cpp index 3983f52..b8ad5d5 100644 --- a/tests/auto/v8/tst_v8.cpp +++ b/tests/auto/v8/tst_v8.cpp @@ -66,6 +66,7 @@ private slots: void fallbackpropertyhandler_callbacks(); void fallbackpropertyhandler_in_prototype(); void fallbackpropertyhandler_nonempty(); + void completehash(); }; void tst_v8::eval() @@ -128,6 +129,11 @@ void tst_v8::fallbackpropertyhandler_nonempty() QVERIFY(v8test_fallbackpropertyhandler_nonempty()); } +void tst_v8::completehash() +{ + QVERIFY(v8test_completehash()); +} + int main(int argc, char *argv[]) { V8::SetFlagsFromCommandLine(&argc, argv, true); diff --git a/tests/auto/v8/v8test.cpp b/tests/auto/v8/v8test.cpp index 9d59d89..09410a6 100644 --- a/tests/auto/v8/v8test.cpp +++ b/tests/auto/v8/v8test.cpp @@ -1041,3 +1041,51 @@ cleanup: ENDTEST(); } + +bool v8test_completehash() +{ +#define HASH_EQUALS(str1, str2) \ +{ \ + String::CompleteHashData hash1 = str1->CompleteHash(); \ + String::CompleteHashData hash2 = str2->CompleteHash(); \ + VERIFY(hash1.length == hash2.length); \ + VERIFY(hash1.symbol_id == hash2.symbol_id || (hash1.symbol_id == 0 || hash2.symbol_id == 0)); \ + VERIFY(hash1.hash == hash2.hash); \ +}; + + BEGINTEST(); + + HandleScope handle_scope; + Persistent<Context> context = Context::New(); + Context::Scope context_scope(context); + + Local<String> str; + Local<String> str2; + uint16_t input[] = { 'I', 'n', 'p', 'u', 't', 0 }; + + str = String::New("Input"); + str2 = String::New("Input"); + HASH_EQUALS(str, str2); + + str = String::New(input); + str2 = String::New(input); + HASH_EQUALS(str, str2); + + str = String::NewSymbol("input"); + str2 = String::NewSymbol("input"); + HASH_EQUALS(str, str2); + + str = CompileRun("var input = \"{ \\\"abc\\\": \\\"value\\\" }\"; input")->ToString(); + str2 = CompileRun("var input2 = \"{ \\\"abc\\\": \\\"value\\\" }\"; input2")->ToString(); + HASH_EQUALS(str, str2); + + // SubStringAsciiSymbolKey is created via the built-in JSON parser for + // property names. + str = CompileRun("JSON.parse(input)")->ToObject()->GetOwnPropertyNames()->Get(0)->ToString(); + str2 = CompileRun("JSON.parse(input2)")->ToObject()->GetOwnPropertyNames()->Get(0)->ToString(); + HASH_EQUALS(str, str2); +cleanup: + context.Dispose(); + + ENDTEST(); +} diff --git a/tests/auto/v8/v8test.h b/tests/auto/v8/v8test.h index 0b9a32b..c195b67 100644 --- a/tests/auto/v8/v8test.h +++ b/tests/auto/v8/v8test.h @@ -60,6 +60,7 @@ bool v8test_qtbug_24871(); bool v8test_fallbackpropertyhandler_callbacks(); bool v8test_fallbackpropertyhandler_in_prototype(); bool v8test_fallbackpropertyhandler_nonempty(); +bool v8test_completehash(); #endif // V8TEST_H |