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 21929 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
21940 v8::HandleScope scope(isolate); | 21940 v8::HandleScope scope(isolate); |
21941 Local<FunctionTemplate> templ = FunctionTemplate::New(isolate, | 21941 Local<FunctionTemplate> templ = FunctionTemplate::New(isolate, |
21942 DummyCallHandler); | 21942 DummyCallHandler); |
21943 CompileRun("for (var i = 0; i < 128; i++) Object.prototype[i] = 0;"); | 21943 CompileRun("for (var i = 0; i < 128; i++) Object.prototype[i] = 0;"); |
21944 Local<Function> function = | 21944 Local<Function> function = |
21945 templ->GetFunction(context.local()).ToLocalChecked(); | 21945 templ->GetFunction(context.local()).ToLocalChecked(); |
21946 CHECK(!function.IsEmpty()); | 21946 CHECK(!function.IsEmpty()); |
21947 CHECK(function->IsFunction()); | 21947 CHECK(function->IsFunction()); |
21948 } | 21948 } |
21949 | 21949 |
21950 | |
21951 THREADED_TEST(JSONParseObject) { | 21950 THREADED_TEST(JSONParseObject) { |
21952 LocalContext context; | 21951 LocalContext context; |
21953 HandleScope scope(context->GetIsolate()); | 21952 HandleScope scope(context->GetIsolate()); |
21954 Local<Value> obj = | 21953 Local<Value> obj = |
21955 v8::JSON::Parse(context->GetIsolate(), v8_str("{\"x\":42}")) | 21954 v8::JSON::Parse(context.local(), v8_str("{\"x\":42}")).ToLocalChecked(); |
21956 .ToLocalChecked(); | |
21957 Local<Object> global = context->Global(); | 21955 Local<Object> global = context->Global(); |
21958 global->Set(context.local(), v8_str("obj"), obj).FromJust(); | 21956 global->Set(context.local(), v8_str("obj"), obj).FromJust(); |
21959 ExpectString("JSON.stringify(obj)", "{\"x\":42}"); | 21957 ExpectString("JSON.stringify(obj)", "{\"x\":42}"); |
21960 } | 21958 } |
21961 | 21959 |
haavardm
2016/04/15 11:45:23
"git cl format" wants only one empty line here bet
jochen (gone - plz use gerrit)
2016/04/15 11:53:27
yeah, we decided to not mass-update but change tho
| |
21962 | |
21963 THREADED_TEST(JSONParseNumber) { | 21960 THREADED_TEST(JSONParseNumber) { |
21964 LocalContext context; | 21961 LocalContext context; |
21965 HandleScope scope(context->GetIsolate()); | 21962 HandleScope scope(context->GetIsolate()); |
21966 Local<Value> obj = | 21963 Local<Value> obj = |
21967 v8::JSON::Parse(context->GetIsolate(), v8_str("42")).ToLocalChecked(); | 21964 v8::JSON::Parse(context.local(), v8_str("42")).ToLocalChecked(); |
21968 Local<Object> global = context->Global(); | 21965 Local<Object> global = context->Global(); |
21969 global->Set(context.local(), v8_str("obj"), obj).FromJust(); | 21966 global->Set(context.local(), v8_str("obj"), obj).FromJust(); |
21970 ExpectString("JSON.stringify(obj)", "42"); | 21967 ExpectString("JSON.stringify(obj)", "42"); |
21971 } | 21968 } |
21972 | 21969 |
21970 THREADED_TEST(JSONStringifyObject) { | |
21971 LocalContext context; | |
21972 HandleScope scope(context->GetIsolate()); | |
21973 Local<Value> value = | |
21974 v8::JSON::Parse(context.local(), v8_str("{\"x\":42}")).ToLocalChecked(); | |
21975 Local<Object> obj = value->ToObject(context.local()).ToLocalChecked(); | |
21976 Local<Object> global = context->Global(); | |
21977 global->Set(context.local(), v8_str("obj"), obj).FromJust(); | |
21978 Local<String> json = | |
21979 v8::JSON::Stringify(context.local(), obj).ToLocalChecked(); | |
21980 v8::String::Utf8Value utf8(json); | |
21981 ExpectString("JSON.stringify(obj)", *utf8); | |
21982 } | |
21973 | 21983 |
21974 #if V8_OS_POSIX && !V8_OS_NACL | 21984 #if V8_OS_POSIX && !V8_OS_NACL |
21975 class ThreadInterruptTest { | 21985 class ThreadInterruptTest { |
21976 public: | 21986 public: |
21977 ThreadInterruptTest() : sem_(0), sem_value_(0) { } | 21987 ThreadInterruptTest() : sem_(0), sem_value_(0) { } |
21978 ~ThreadInterruptTest() {} | 21988 ~ThreadInterruptTest() {} |
21979 | 21989 |
21980 void RunTest() { | 21990 void RunTest() { |
21981 InterruptThread i_thread(this); | 21991 InterruptThread i_thread(this); |
21982 i_thread.Start(); | 21992 i_thread.Start(); |
(...skipping 2995 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
24978 } | 24988 } |
24979 delete garbage; | 24989 delete garbage; |
24980 // Check that moderate memory pressure notification sets GC into memory | 24990 // Check that moderate memory pressure notification sets GC into memory |
24981 // optimizing mode. | 24991 // optimizing mode. |
24982 isolate->MemoryPressureNotification(v8::MemoryPressureLevel::kModerate); | 24992 isolate->MemoryPressureNotification(v8::MemoryPressureLevel::kModerate); |
24983 CHECK(CcTest::i_isolate()->heap()->ShouldOptimizeForMemoryUsage()); | 24993 CHECK(CcTest::i_isolate()->heap()->ShouldOptimizeForMemoryUsage()); |
24984 // Check that disabling memory pressure returns GC into normal mode. | 24994 // Check that disabling memory pressure returns GC into normal mode. |
24985 isolate->MemoryPressureNotification(v8::MemoryPressureLevel::kNone); | 24995 isolate->MemoryPressureNotification(v8::MemoryPressureLevel::kNone); |
24986 CHECK(!CcTest::i_isolate()->heap()->ShouldOptimizeForMemoryUsage()); | 24996 CHECK(!CcTest::i_isolate()->heap()->ShouldOptimizeForMemoryUsage()); |
24987 } | 24997 } |
OLD | NEW |