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

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

Issue 24360017: Expose SameValue equality comparison algorithm (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: Created 7 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
« src/objects.cc ('K') | « src/objects.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 4955 matching lines...) Expand 10 before | Expand all | Expand 10 after
4966 CHECK_EQ(v8_num(1), v8_num(1)); 4966 CHECK_EQ(v8_num(1), v8_num(1));
4967 CHECK_EQ(v8_num(1.00), v8_num(1)); 4967 CHECK_EQ(v8_num(1.00), v8_num(1));
4968 CHECK_NE(v8_num(1), v8_num(2)); 4968 CHECK_NE(v8_num(1), v8_num(2));
4969 4969
4970 // Assume String is not internalized. 4970 // Assume String is not internalized.
4971 CHECK(v8_str("a")->StrictEquals(v8_str("a"))); 4971 CHECK(v8_str("a")->StrictEquals(v8_str("a")));
4972 CHECK(!v8_str("a")->StrictEquals(v8_str("b"))); 4972 CHECK(!v8_str("a")->StrictEquals(v8_str("b")));
4973 CHECK(!v8_str("5")->StrictEquals(v8_num(5))); 4973 CHECK(!v8_str("5")->StrictEquals(v8_num(5)));
4974 CHECK(v8_num(1)->StrictEquals(v8_num(1))); 4974 CHECK(v8_num(1)->StrictEquals(v8_num(1)));
4975 CHECK(!v8_num(1)->StrictEquals(v8_num(2))); 4975 CHECK(!v8_num(1)->StrictEquals(v8_num(2)));
4976 CHECK(v8_num(0)->StrictEquals(v8_num(-0))); 4976 CHECK(v8_num(0.0)->StrictEquals(v8_num(-0.0)));
yusukesuzuki 2013/09/24 12:58:26 Since 0 is int, static_cast<double>(-0) becomes 0.
4977 Local<Value> not_a_number = v8_num(i::OS::nan_value()); 4977 Local<Value> not_a_number = v8_num(i::OS::nan_value());
4978 CHECK(!not_a_number->StrictEquals(not_a_number)); 4978 CHECK(!not_a_number->StrictEquals(not_a_number));
4979 CHECK(v8::False()->StrictEquals(v8::False())); 4979 CHECK(v8::False()->StrictEquals(v8::False()));
4980 CHECK(!v8::False()->StrictEquals(v8::Undefined())); 4980 CHECK(!v8::False()->StrictEquals(v8::Undefined()));
4981 4981
4982 v8::Handle<v8::Object> obj = v8::Object::New(); 4982 v8::Handle<v8::Object> obj = v8::Object::New();
4983 v8::Persistent<v8::Object> alias(isolate, obj); 4983 v8::Persistent<v8::Object> alias(isolate, obj);
4984 CHECK(v8::Local<v8::Object>::New(isolate, alias)->StrictEquals(obj)); 4984 CHECK(v8::Local<v8::Object>::New(isolate, alias)->StrictEquals(obj));
4985 alias.Dispose(); 4985 alias.Dispose();
4986
4987 CHECK(v8_str("a")->SameValue(v8_str("a")));
4988 CHECK(!v8_str("a")->SameValue(v8_str("b")));
4989 CHECK(!v8_str("5")->SameValue(v8_num(5)));
4990 CHECK(v8_num(1)->SameValue(v8_num(1)));
4991 CHECK(!v8_num(1)->SameValue(v8_num(2)));
4992 CHECK(!v8_num(0.0)->SameValue(v8_num(-0.0)));
yusukesuzuki 2013/09/24 12:58:26 `SameValue(0.0, -0.0)` becomes false.
4993 CHECK(not_a_number->SameValue(not_a_number));
yusukesuzuki 2013/09/24 12:58:26 `SameValue(NaN, NaN)` becomes true.
4994 CHECK(v8::False()->SameValue(v8::False()));
4995 CHECK(!v8::False()->SameValue(v8::Undefined()));
4986 } 4996 }
4987 4997
4988 4998
4989 THREADED_TEST(MultiRun) { 4999 THREADED_TEST(MultiRun) {
4990 LocalContext context; 5000 LocalContext context;
4991 v8::HandleScope scope(context->GetIsolate()); 5001 v8::HandleScope scope(context->GetIsolate());
4992 Local<Script> script = Script::Compile(v8_str("x")); 5002 Local<Script> script = Script::Compile(v8_str("x"));
4993 for (int i = 0; i < 10; i++) 5003 for (int i = 0; i < 10; i++)
4994 script->Run(); 5004 script->Run();
4995 } 5005 }
(...skipping 15571 matching lines...) Expand 10 before | Expand all | Expand 10 after
20567 Local<Object> data2 = v8::Object::New(); 20577 Local<Object> data2 = v8::Object::New();
20568 function_new_expected_env = data2; 20578 function_new_expected_env = data2;
20569 Local<Function> func2 = Function::New(isolate, FunctionNewCallback, data2); 20579 Local<Function> func2 = Function::New(isolate, FunctionNewCallback, data2);
20570 CHECK(!func2->IsNull()); 20580 CHECK(!func2->IsNull());
20571 CHECK_NE(func, func2); 20581 CHECK_NE(func, func2);
20572 env->Global()->Set(v8_str("func2"), func2); 20582 env->Global()->Set(v8_str("func2"), func2);
20573 Local<Value> result2 = CompileRun("func2();"); 20583 Local<Value> result2 = CompileRun("func2();");
20574 CHECK_EQ(v8::Integer::New(17, isolate), result2); 20584 CHECK_EQ(v8::Integer::New(17, isolate), result2);
20575 } 20585 }
20576 20586
OLDNEW
« src/objects.cc ('K') | « src/objects.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698