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

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

Issue 1157453002: Add basic API support for Map & Set (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 7 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
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 21106 matching lines...) Expand 10 before | Expand all | Expand 10 after
21117 // add the testExtraShouldReturnFive export 21117 // add the testExtraShouldReturnFive export
21118 v8::Local<v8::Object> exports = env->GetExtrasExportsObject(); 21118 v8::Local<v8::Object> exports = env->GetExtrasExportsObject();
21119 21119
21120 auto func = 21120 auto func =
21121 exports->Get(v8_str("testExtraShouldReturnFive")).As<v8::Function>(); 21121 exports->Get(v8_str("testExtraShouldReturnFive")).As<v8::Function>();
21122 auto undefined = v8::Undefined(isolate); 21122 auto undefined = v8::Undefined(isolate);
21123 auto result = func->Call(undefined, 0, {}).As<v8::Number>(); 21123 auto result = func->Call(undefined, 0, {}).As<v8::Number>();
21124 21124
21125 CHECK(result->Value() == 5.0); 21125 CHECK(result->Value() == 5.0);
21126 } 21126 }
21127
21128
21129 TEST(Map) {
21130 v8::Isolate* isolate = CcTest::isolate();
21131 v8::HandleScope handle_scope(isolate);
21132 LocalContext env;
21133
21134 v8::Local<v8::Map> map = v8::Map::New(isolate);
21135 CHECK(map->IsObject());
21136 CHECK(map->IsMap());
21137 CHECK_EQ(0, map->Size());
21138
21139 v8::Local<v8::Value> val = CompileRun("new Map([[1, 2], [3, 4]])");
21140 CHECK(val->IsMap());
21141 map = v8::Local<v8::Map>::Cast(val);
21142 CHECK_EQ(2, map->Size());
21143 }
21144
21145
21146 TEST(Set) {
21147 v8::Isolate* isolate = CcTest::isolate();
21148 v8::HandleScope handle_scope(isolate);
21149 LocalContext env;
21150
21151 v8::Local<v8::Set> set = v8::Set::New(isolate);
21152 CHECK(set->IsObject());
21153 CHECK(set->IsSet());
21154 CHECK_EQ(0, set->Size());
21155
21156 v8::Local<v8::Value> val = CompileRun("new Set([1, 2])");
21157 CHECK(val->IsSet());
21158 set = v8::Local<v8::Set>::Cast(val);
21159 CHECK_EQ(2, set->Size());
21160 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698