Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1129)

Unified Diff: test/cctest/test-api.cc

Issue 1891203002: Expose JSON stringifier through V8 API (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fixed compile error on linux Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: test/cctest/test-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index 6bea3eaefee603ed7bc02a56be251082ba6ad27a..4bc470df5f0c6e25350bf1983f328c04f48c2c14 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -21947,29 +21947,39 @@ THREADED_TEST(Regress260106) {
CHECK(function->IsFunction());
}
-
THREADED_TEST(JSONParseObject) {
LocalContext context;
HandleScope scope(context->GetIsolate());
Local<Value> obj =
- v8::JSON::Parse(context->GetIsolate(), v8_str("{\"x\":42}"))
- .ToLocalChecked();
+ v8::JSON::Parse(context.local(), v8_str("{\"x\":42}")).ToLocalChecked();
Local<Object> global = context->Global();
global->Set(context.local(), v8_str("obj"), obj).FromJust();
ExpectString("JSON.stringify(obj)", "{\"x\":42}");
}
-
THREADED_TEST(JSONParseNumber) {
LocalContext context;
HandleScope scope(context->GetIsolate());
Local<Value> obj =
- v8::JSON::Parse(context->GetIsolate(), v8_str("42")).ToLocalChecked();
+ v8::JSON::Parse(context.local(), v8_str("42")).ToLocalChecked();
Local<Object> global = context->Global();
global->Set(context.local(), v8_str("obj"), obj).FromJust();
ExpectString("JSON.stringify(obj)", "42");
}
+THREADED_TEST(JSONStringifyObject) {
+ LocalContext context;
+ HandleScope scope(context->GetIsolate());
+ Local<Value> value =
+ v8::JSON::Parse(context.local(), v8_str("{\"x\":42}")).ToLocalChecked();
+ Local<Object> obj = value->ToObject(context.local()).ToLocalChecked();
+ Local<Object> global = context->Global();
+ global->Set(context.local(), v8_str("obj"), obj).FromJust();
+ Local<String> json =
+ v8::JSON::Stringify(context.local(), obj).ToLocalChecked();
+ v8::String::Utf8Value utf8(json);
+ ExpectString("JSON.stringify(obj)", *utf8);
+}
#if V8_OS_POSIX && !V8_OS_NACL
class ThreadInterruptTest {
« src/api.cc ('K') | « src/runtime/runtime-object.cc ('k') | test/fuzzer/json.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698