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

Side by Side Diff: test/cctest/test-random.cc

Issue 12716010: Added a version of the v8::HandleScope constructor with an Isolate and use that consistently. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Feedback. Rebased Created 7 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « test/cctest/test-profile-generator.cc ('k') | test/cctest/test-regexp.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 V8::FillHeapNumberWithRandom(*value, *context); 66 V8::FillHeapNumberWithRandom(*value, *context);
67 double runtime_value = HeapNumber::cast(*value)->value(); 67 double runtime_value = HeapNumber::cast(*value)->value();
68 CHECK_EQ(runtime_value, crankshaft_value); 68 CHECK_EQ(runtime_value, crankshaft_value);
69 } 69 }
70 70
71 71
72 TEST(CrankshaftRandom) { 72 TEST(CrankshaftRandom) {
73 if (env.IsEmpty()) env = v8::Context::New(); 73 if (env.IsEmpty()) env = v8::Context::New();
74 // Skip test if crankshaft is disabled. 74 // Skip test if crankshaft is disabled.
75 if (!V8::UseCrankshaft()) return; 75 if (!V8::UseCrankshaft()) return;
76 v8::HandleScope scope; 76 v8::HandleScope scope(env->GetIsolate());
77 env->Enter(); 77 env->Enter();
78 78
79 Handle<Context> context(Isolate::Current()->context()); 79 Handle<Context> context(Isolate::Current()->context());
80 Handle<JSObject> global(context->global_object()); 80 Handle<JSObject> global(context->global_object());
81 Handle<ByteArray> seeds(context->random_seed()); 81 Handle<ByteArray> seeds(context->random_seed());
82 bool has_pending_exception; 82 bool has_pending_exception;
83 83
84 CompileRun("function f() { return Math.random(); }"); 84 CompileRun("function f() { return Math.random(); }");
85 85
86 Object* string = FACTORY->InternalizeOneByteString(STATIC_ASCII_VECTOR("f"))-> 86 Object* string = FACTORY->InternalizeOneByteString(STATIC_ASCII_VECTOR("f"))->
(...skipping 14 matching lines...) Expand all
101 101
102 // Test that we bail out to runtime when seeds are uninitialized (zeros). 102 // Test that we bail out to runtime when seeds are uninitialized (zeros).
103 SetSeeds(seeds, 0, 0); 103 SetSeeds(seeds, 0, 0);
104 Handle<Object> value = 104 Handle<Object> value =
105 Execution::Call(fun, global, 0, NULL, &has_pending_exception); 105 Execution::Call(fun, global, 0, NULL, &has_pending_exception);
106 CHECK(value->IsHeapNumber()); 106 CHECK(value->IsHeapNumber());
107 CHECK(fun->IsOptimized()); 107 CHECK(fun->IsOptimized());
108 double crankshaft_value = HeapNumber::cast(*value)->value(); 108 double crankshaft_value = HeapNumber::cast(*value)->value();
109 CHECK_NE(0.0, crankshaft_value); 109 CHECK_NE(0.0, crankshaft_value);
110 } 110 }
OLDNEW
« no previous file with comments | « test/cctest/test-profile-generator.cc ('k') | test/cctest/test-regexp.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698