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

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

Issue 608503002: Add IsGeneratorFunction and IsGeneratorObject checks to v8::Value. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 2 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 | « src/api.cc ('k') | no next file » | 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 1524 matching lines...) Expand 10 before | Expand all | Expand 10 after
1535 v8::Handle<Value> syntax_error = CompileRun( 1535 v8::Handle<Value> syntax_error = CompileRun(
1536 "var out = 0; try { eval(\"#\"); } catch(x) { out = x; } out; "); 1536 "var out = 0; try { eval(\"#\"); } catch(x) { out = x; } out; ");
1537 CHECK(syntax_error->IsNativeError()); 1537 CHECK(syntax_error->IsNativeError());
1538 v8::Handle<Value> not_error = CompileRun("{a:42}"); 1538 v8::Handle<Value> not_error = CompileRun("{a:42}");
1539 CHECK(!not_error->IsNativeError()); 1539 CHECK(!not_error->IsNativeError());
1540 v8::Handle<Value> not_object = CompileRun("42"); 1540 v8::Handle<Value> not_object = CompileRun("42");
1541 CHECK(!not_object->IsNativeError()); 1541 CHECK(!not_object->IsNativeError());
1542 } 1542 }
1543 1543
1544 1544
1545 THREADED_TEST(IsGeneratorFunctionOrObject) {
1546 LocalContext env;
1547 v8::HandleScope scope(env->GetIsolate());
1548
1549 CompileRun("function *gen() { yield 1; }\nfunction func() {}");
1550 v8::Handle<Value> gen = CompileRun("gen");
1551 v8::Handle<Value> genObj = CompileRun("gen()");
1552 v8::Handle<Value> object = CompileRun("{a:42}");
1553 v8::Handle<Value> func = CompileRun("func");
1554
1555 CHECK(gen->IsGeneratorFunction());
1556 CHECK(gen->IsFunction());
1557 CHECK(!gen->IsGeneratorObject());
1558
1559 CHECK(!genObj->IsGeneratorFunction());
1560 CHECK(!genObj->IsFunction());
1561 CHECK(genObj->IsGeneratorObject());
1562
1563 CHECK(!object->IsGeneratorFunction());
1564 CHECK(!object->IsFunction());
1565 CHECK(!object->IsGeneratorObject());
1566
1567 CHECK(!func->IsGeneratorFunction());
1568 CHECK(func->IsFunction());
1569 CHECK(!func->IsGeneratorObject());
1570 }
1571
1572
1545 THREADED_TEST(ArgumentsObject) { 1573 THREADED_TEST(ArgumentsObject) {
1546 LocalContext env; 1574 LocalContext env;
1547 v8::HandleScope scope(env->GetIsolate()); 1575 v8::HandleScope scope(env->GetIsolate());
1548 v8::Handle<Value> arguments_object = 1576 v8::Handle<Value> arguments_object =
1549 CompileRun("var out = 0; (function(){ out = arguments; })(1,2,3); out;"); 1577 CompileRun("var out = 0; (function(){ out = arguments; })(1,2,3); out;");
1550 CHECK(arguments_object->IsArgumentsObject()); 1578 CHECK(arguments_object->IsArgumentsObject());
1551 v8::Handle<Value> array = CompileRun("[1,2,3]"); 1579 v8::Handle<Value> array = CompileRun("[1,2,3]");
1552 CHECK(!array->IsArgumentsObject()); 1580 CHECK(!array->IsArgumentsObject());
1553 v8::Handle<Value> object = CompileRun("{a:42}"); 1581 v8::Handle<Value> object = CompileRun("{a:42}");
1554 CHECK(!object->IsArgumentsObject()); 1582 CHECK(!object->IsArgumentsObject());
(...skipping 21772 matching lines...) Expand 10 before | Expand all | Expand 10 after
23327 // TestSourceStream::GetMoreData won't block, so it's OK to just run the 23355 // TestSourceStream::GetMoreData won't block, so it's OK to just run the
23328 // task here in the main thread. 23356 // task here in the main thread.
23329 task->Run(); 23357 task->Run();
23330 delete task; 23358 delete task;
23331 23359
23332 const v8::ScriptCompiler::CachedData* cached_data = source.GetCachedData(); 23360 const v8::ScriptCompiler::CachedData* cached_data = source.GetCachedData();
23333 CHECK(cached_data != NULL); 23361 CHECK(cached_data != NULL);
23334 CHECK(cached_data->data != NULL); 23362 CHECK(cached_data->data != NULL);
23335 CHECK_GT(cached_data->length, 0); 23363 CHECK_GT(cached_data->length, 0);
23336 } 23364 }
OLDNEW
« no previous file with comments | « src/api.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698