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

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

Issue 310063002: Add tests for FuncNameInferrer. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: . Created 6 years, 6 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/cctest.h ('k') | test/cctest/test-parsing.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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 v8::Local<v8::String> profile_name = 92 v8::Local<v8::String> profile_name =
93 v8::String::NewFromUtf8(env->GetIsolate(), "my_profile1"); 93 v8::String::NewFromUtf8(env->GetIsolate(), "my_profile1");
94 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler(); 94 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler();
95 95
96 cpu_profiler->StartProfiling(profile_name); 96 cpu_profiler->StartProfiling(profile_name);
97 (*test)(); 97 (*test)();
98 reinterpret_cast<i::CpuProfiler*>(cpu_profiler)->DeleteAllProfiles(); 98 reinterpret_cast<i::CpuProfiler*>(cpu_profiler)->DeleteAllProfiles();
99 } 99 }
100 100
101 101
102 static void ExpectString(const char* code, const char* expected) {
103 Local<Value> result = CompileRun(code);
104 CHECK(result->IsString());
105 String::Utf8Value utf8(result);
106 CHECK_EQ(expected, *utf8);
107 }
108
109
110 static void ExpectInt32(const char* code, int expected) {
111 Local<Value> result = CompileRun(code);
112 CHECK(result->IsInt32());
113 CHECK_EQ(expected, result->Int32Value());
114 }
115
116
117 static void ExpectBoolean(const char* code, bool expected) {
118 Local<Value> result = CompileRun(code);
119 CHECK(result->IsBoolean());
120 CHECK_EQ(expected, result->BooleanValue());
121 }
122
123
124 static void ExpectTrue(const char* code) {
125 ExpectBoolean(code, true);
126 }
127
128
129 static void ExpectFalse(const char* code) {
130 ExpectBoolean(code, false);
131 }
132
133
134 static void ExpectObject(const char* code, Local<Value> expected) {
135 Local<Value> result = CompileRun(code);
136 CHECK(result->Equals(expected));
137 }
138
139
140 static void ExpectUndefined(const char* code) {
141 Local<Value> result = CompileRun(code);
142 CHECK(result->IsUndefined());
143 }
144
145
146 static int signature_callback_count; 102 static int signature_callback_count;
147 static Local<Value> signature_expected_receiver; 103 static Local<Value> signature_expected_receiver;
148 static void IncrementingSignatureCallback( 104 static void IncrementingSignatureCallback(
149 const v8::FunctionCallbackInfo<v8::Value>& args) { 105 const v8::FunctionCallbackInfo<v8::Value>& args) {
150 ApiTestFuzzer::Fuzz(); 106 ApiTestFuzzer::Fuzz();
151 signature_callback_count++; 107 signature_callback_count++;
152 CHECK_EQ(signature_expected_receiver, args.Holder()); 108 CHECK_EQ(signature_expected_receiver, args.Holder());
153 CHECK_EQ(signature_expected_receiver, args.This()); 109 CHECK_EQ(signature_expected_receiver, args.This());
154 v8::Handle<v8::Array> result = 110 v8::Handle<v8::Array> result =
155 v8::Array::New(args.GetIsolate(), args.Length()); 111 v8::Array::New(args.GetIsolate(), args.Length());
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 400
445 THREADED_TEST(Script) { 401 THREADED_TEST(Script) {
446 LocalContext env; 402 LocalContext env;
447 v8::HandleScope scope(env->GetIsolate()); 403 v8::HandleScope scope(env->GetIsolate());
448 const char* source = "1 + 2 + 3"; 404 const char* source = "1 + 2 + 3";
449 Local<Script> script = v8_compile(source); 405 Local<Script> script = v8_compile(source);
450 CHECK_EQ(6, script->Run()->Int32Value()); 406 CHECK_EQ(6, script->Run()->Int32Value());
451 } 407 }
452 408
453 409
454 static uint16_t* AsciiToTwoByteString(const char* source) {
455 int array_length = i::StrLength(source) + 1;
456 uint16_t* converted = i::NewArray<uint16_t>(array_length);
457 for (int i = 0; i < array_length; i++) converted[i] = source[i];
458 return converted;
459 }
460
461
462 class TestResource: public String::ExternalStringResource { 410 class TestResource: public String::ExternalStringResource {
463 public: 411 public:
464 TestResource(uint16_t* data, int* counter = NULL, bool owning_data = true) 412 TestResource(uint16_t* data, int* counter = NULL, bool owning_data = true)
465 : data_(data), length_(0), counter_(counter), owning_data_(owning_data) { 413 : data_(data), length_(0), counter_(counter), owning_data_(owning_data) {
466 while (data[length_]) ++length_; 414 while (data[length_]) ++length_;
467 } 415 }
468 416
469 ~TestResource() { 417 ~TestResource() {
470 if (owning_data_) i::DeleteArray(data_); 418 if (owning_data_) i::DeleteArray(data_);
471 if (counter_ != NULL) ++*counter_; 419 if (counter_ != NULL) ++*counter_;
(...skipping 22225 matching lines...) Expand 10 before | Expand all | Expand 10 after
22697 Local<Script> script = v8::ScriptCompiler::Compile( 22645 Local<Script> script = v8::ScriptCompiler::Compile(
22698 isolate, &script_source); 22646 isolate, &script_source);
22699 Local<Value> script_name = script->GetUnboundScript()->GetScriptName(); 22647 Local<Value> script_name = script->GetUnboundScript()->GetScriptName();
22700 CHECK(!script_name.IsEmpty()); 22648 CHECK(!script_name.IsEmpty());
22701 CHECK(script_name->IsString()); 22649 CHECK(script_name->IsString());
22702 String::Utf8Value utf8_name(script_name); 22650 String::Utf8Value utf8_name(script_name);
22703 CHECK_EQ(url, *utf8_name); 22651 CHECK_EQ(url, *utf8_name);
22704 int line_number = script->GetUnboundScript()->GetLineNumber(0); 22652 int line_number = script->GetUnboundScript()->GetLineNumber(0);
22705 CHECK_EQ(13, line_number); 22653 CHECK_EQ(13, line_number);
22706 } 22654 }
OLDNEW
« no previous file with comments | « test/cctest/cctest.h ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698