[intrinsics] Remove obsolete intrinsics.
Remove obsolete definitions from macros.py, and drop the now obsolete %_ToPrimitive, %_ToPrimitive_Number, %_ToPrimitive_String, %_ToName and the %ToPrimitive_String intrinsics/runtime entries. R=yangguo@chromium.org BUG=v8:5049 Review-Url: https://codereview.chromium.org/2137203002 Cr-Commit-Position: refs/heads/master@{#37665}
This commit is contained in:
parent
bbb2159d4c
commit
4e862dd964
@ -1214,6 +1214,9 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
|
||||
SimpleInstallFunction(isolate->initial_object_prototype(),
|
||||
"__lookupSetter__", Builtins::kObjectLookupSetter, 1,
|
||||
true);
|
||||
SimpleInstallFunction(
|
||||
isolate->initial_object_prototype(), "propertyIsEnumerable",
|
||||
Builtins::kObjectPrototypePropertyIsEnumerable, 1, false);
|
||||
}
|
||||
|
||||
Handle<JSObject> global(native_context()->global_object());
|
||||
|
@ -4994,7 +4994,26 @@ BUILTIN(AsyncFunctionConstructor) {
|
||||
return *func;
|
||||
}
|
||||
|
||||
// ES6 19.1.3.6 Object.prototype.toString
|
||||
// -----------------------------------------------------------------------------
|
||||
// ES6 section 19.1 Object Objects
|
||||
|
||||
// ES6 section 19.1.3.4 Object.prototype.propertyIsEnumerable ( V )
|
||||
BUILTIN(ObjectPrototypePropertyIsEnumerable) {
|
||||
HandleScope scope(isolate);
|
||||
Handle<JSReceiver> object;
|
||||
Handle<Name> name;
|
||||
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
|
||||
isolate, name, Object::ToName(isolate, args.atOrUndefined(isolate, 1)));
|
||||
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
|
||||
isolate, object, JSReceiver::ToObject(isolate, args.receiver()));
|
||||
Maybe<PropertyAttributes> maybe =
|
||||
JSReceiver::GetOwnPropertyAttributes(object, name);
|
||||
if (!maybe.IsJust()) return isolate->heap()->exception();
|
||||
if (maybe.FromJust() == ABSENT) return isolate->heap()->false_value();
|
||||
return isolate->heap()->ToBoolean((maybe.FromJust() & DONT_ENUM) == 0);
|
||||
}
|
||||
|
||||
// ES6 section 19.1.3.6 Object.prototype.toString
|
||||
BUILTIN(ObjectProtoToString) {
|
||||
HandleScope scope(isolate);
|
||||
Handle<Object> object = args.at<Object>(0);
|
||||
|
@ -145,6 +145,7 @@ class CodeStubAssembler;
|
||||
V(ObjectLookupGetter, BUILTIN_EXIT) \
|
||||
V(ObjectLookupSetter, BUILTIN_EXIT) \
|
||||
V(ObjectPreventExtensions, BUILTIN_EXIT) \
|
||||
V(ObjectPrototypePropertyIsEnumerable, BUILTIN_EXIT) \
|
||||
V(ObjectProtoToString, BUILTIN_EXIT) \
|
||||
V(ObjectSeal, BUILTIN_EXIT) \
|
||||
V(ObjectValues, BUILTIN_EXIT) \
|
||||
|
@ -68,14 +68,10 @@ Reduction JSIntrinsicLowering::Reduce(Node* node) {
|
||||
return ReduceToInteger(node);
|
||||
case Runtime::kInlineToLength:
|
||||
return ReduceToLength(node);
|
||||
case Runtime::kInlineToName:
|
||||
return ReduceToName(node);
|
||||
case Runtime::kInlineToNumber:
|
||||
return ReduceToNumber(node);
|
||||
case Runtime::kInlineToObject:
|
||||
return ReduceToObject(node);
|
||||
case Runtime::kInlineToPrimitive:
|
||||
return ReduceToPrimitive(node);
|
||||
case Runtime::kInlineToString:
|
||||
return ReduceToString(node);
|
||||
case Runtime::kInlineCall:
|
||||
@ -280,12 +276,6 @@ Reduction JSIntrinsicLowering::ReduceToInteger(Node* node) {
|
||||
}
|
||||
|
||||
|
||||
Reduction JSIntrinsicLowering::ReduceToName(Node* node) {
|
||||
NodeProperties::ChangeOp(node, javascript()->ToName());
|
||||
return Changed(node);
|
||||
}
|
||||
|
||||
|
||||
Reduction JSIntrinsicLowering::ReduceToNumber(Node* node) {
|
||||
NodeProperties::ChangeOp(node, javascript()->ToNumber());
|
||||
return Changed(node);
|
||||
@ -304,17 +294,6 @@ Reduction JSIntrinsicLowering::ReduceToObject(Node* node) {
|
||||
}
|
||||
|
||||
|
||||
Reduction JSIntrinsicLowering::ReduceToPrimitive(Node* node) {
|
||||
Node* value = NodeProperties::GetValueInput(node, 0);
|
||||
Type* value_type = NodeProperties::GetType(value);
|
||||
if (value_type->Is(Type::Primitive())) {
|
||||
ReplaceWithValue(node, value);
|
||||
return Replace(value);
|
||||
}
|
||||
return NoChange();
|
||||
}
|
||||
|
||||
|
||||
Reduction JSIntrinsicLowering::ReduceToString(Node* node) {
|
||||
NodeProperties::ChangeOp(node, javascript()->ToString());
|
||||
return Changed(node);
|
||||
|
@ -54,10 +54,8 @@ class JSIntrinsicLowering final : public AdvancedReducer {
|
||||
Reduction ReduceSubString(Node* node);
|
||||
Reduction ReduceToInteger(Node* node);
|
||||
Reduction ReduceToLength(Node* node);
|
||||
Reduction ReduceToName(Node* node);
|
||||
Reduction ReduceToNumber(Node* node);
|
||||
Reduction ReduceToObject(Node* node);
|
||||
Reduction ReduceToPrimitive(Node* node);
|
||||
Reduction ReduceToString(Node* node);
|
||||
Reduction ReduceCall(Node* node);
|
||||
Reduction ReduceNewObject(Node* node);
|
||||
|
@ -188,12 +188,8 @@ bool Linkage::NeedsFrameStateInput(Runtime::FunctionId function) {
|
||||
case Runtime::kInlineThrowNotDateError:
|
||||
case Runtime::kInlineToInteger:
|
||||
case Runtime::kInlineToLength:
|
||||
case Runtime::kInlineToName:
|
||||
case Runtime::kInlineToNumber:
|
||||
case Runtime::kInlineToObject:
|
||||
case Runtime::kInlineToPrimitive:
|
||||
case Runtime::kInlineToPrimitive_Number:
|
||||
case Runtime::kInlineToPrimitive_String:
|
||||
case Runtime::kInlineToString:
|
||||
return true;
|
||||
default:
|
||||
|
@ -1481,16 +1481,10 @@ Type* Typer::Visitor::TypeJSCallRuntime(Node* node) {
|
||||
return TypeUnaryOp(node, ToInteger);
|
||||
case Runtime::kInlineToLength:
|
||||
return TypeUnaryOp(node, ToLength);
|
||||
case Runtime::kInlineToName:
|
||||
return TypeUnaryOp(node, ToName);
|
||||
case Runtime::kInlineToNumber:
|
||||
return TypeUnaryOp(node, ToNumber);
|
||||
case Runtime::kInlineToObject:
|
||||
return TypeUnaryOp(node, ToObject);
|
||||
case Runtime::kInlineToPrimitive:
|
||||
case Runtime::kInlineToPrimitive_Number:
|
||||
case Runtime::kInlineToPrimitive_String:
|
||||
return TypeUnaryOp(node, ToPrimitive);
|
||||
case Runtime::kInlineToString:
|
||||
return TypeUnaryOp(node, ToString);
|
||||
case Runtime::kHasInPrototypeChain:
|
||||
|
@ -12312,29 +12312,6 @@ void HOptimizedGraphBuilder::GenerateToInteger(CallRuntime* call) {
|
||||
}
|
||||
|
||||
|
||||
void HOptimizedGraphBuilder::GenerateToName(CallRuntime* call) {
|
||||
DCHECK_EQ(1, call->arguments()->length());
|
||||
CHECK_ALIVE(VisitForValue(call->arguments()->at(0)));
|
||||
HValue* input = Pop();
|
||||
if (input->type().IsSmi()) {
|
||||
HValue* result = BuildNumberToString(input, Type::SignedSmall());
|
||||
return ast_context()->ReturnValue(result);
|
||||
} else if (input->type().IsTaggedNumber()) {
|
||||
HValue* result = BuildNumberToString(input, Type::Number());
|
||||
return ast_context()->ReturnValue(result);
|
||||
} else if (input->type().IsString()) {
|
||||
return ast_context()->ReturnValue(input);
|
||||
} else {
|
||||
Callable callable = CodeFactory::ToName(isolate());
|
||||
HValue* stub = Add<HConstant>(callable.code());
|
||||
HValue* values[] = {context(), input};
|
||||
HInstruction* result = New<HCallWithDescriptor>(
|
||||
stub, 0, callable.descriptor(), ArrayVector(values));
|
||||
return ast_context()->ReturnInstruction(result, call->id());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void HOptimizedGraphBuilder::GenerateToObject(CallRuntime* call) {
|
||||
DCHECK_EQ(1, call->arguments()->length());
|
||||
CHECK_ALIVE(VisitForValue(call->arguments()->at(0)));
|
||||
|
@ -2217,7 +2217,6 @@ class HOptimizedGraphBuilder : public HGraphBuilder, public AstVisitor {
|
||||
F(NewObject) \
|
||||
F(StringCharFromCode) \
|
||||
F(ToInteger) \
|
||||
F(ToName) \
|
||||
F(ToObject) \
|
||||
F(ToString) \
|
||||
F(ToLength) \
|
||||
|
@ -785,7 +785,7 @@ ObjectMirror.prototype.internalProperties = function() {
|
||||
|
||||
|
||||
ObjectMirror.prototype.property = function(name) {
|
||||
var details = %DebugGetPropertyDetails(this.value_, TO_NAME(name));
|
||||
var details = %DebugGetPropertyDetails(this.value_, name);
|
||||
if (details) {
|
||||
return new PropertyMirror(this, name, details);
|
||||
}
|
||||
|
@ -561,11 +561,6 @@ void FullCodeGenerator::EmitToString(CallRuntime* expr) {
|
||||
}
|
||||
|
||||
|
||||
void FullCodeGenerator::EmitToName(CallRuntime* expr) {
|
||||
EmitIntrinsicAsStubCall(expr, CodeFactory::ToName(isolate()));
|
||||
}
|
||||
|
||||
|
||||
void FullCodeGenerator::EmitToLength(CallRuntime* expr) {
|
||||
EmitIntrinsicAsStubCall(expr, CodeFactory::ToLength(isolate()));
|
||||
}
|
||||
|
@ -527,7 +527,6 @@ class FullCodeGenerator: public AstVisitor {
|
||||
F(ToString) \
|
||||
F(ToLength) \
|
||||
F(ToNumber) \
|
||||
F(ToName) \
|
||||
F(ToObject) \
|
||||
F(DebugIsActive) \
|
||||
F(CreateIterResultObject)
|
||||
|
@ -269,10 +269,6 @@ Node* IntrinsicsHelper::ToString(Node* input, Node* arg_count, Node* context) {
|
||||
return IntrinsicAsStubCall(input, context, CodeFactory::ToString(isolate()));
|
||||
}
|
||||
|
||||
Node* IntrinsicsHelper::ToName(Node* input, Node* arg_count, Node* context) {
|
||||
return IntrinsicAsStubCall(input, context, CodeFactory::ToName(isolate()));
|
||||
}
|
||||
|
||||
Node* IntrinsicsHelper::ToLength(Node* input, Node* arg_count, Node* context) {
|
||||
return IntrinsicAsStubCall(input, context, CodeFactory::ToLength(isolate()));
|
||||
}
|
||||
|
@ -40,7 +40,6 @@ namespace interpreter {
|
||||
V(RegExpExec, reg_exp_exec, 4) \
|
||||
V(SubString, sub_string, 3) \
|
||||
V(ToString, to_string, 1) \
|
||||
V(ToName, to_name, 1) \
|
||||
V(ToLength, to_length, 1) \
|
||||
V(ToInteger, to_integer, 1) \
|
||||
V(ToNumber, to_number, 1) \
|
||||
|
@ -32,12 +32,6 @@ define NONE = 0;
|
||||
define READ_ONLY = 1;
|
||||
define DONT_ENUM = 2;
|
||||
define DONT_DELETE = 4;
|
||||
define NEW_ONE_BYTE_STRING = true;
|
||||
define NEW_TWO_BYTE_STRING = false;
|
||||
|
||||
# Constants used for getter and setter operations.
|
||||
define GETTER = 0;
|
||||
define SETTER = 1;
|
||||
|
||||
# 2^53 - 1
|
||||
define kMaxSafeInteger = 9007199254740991;
|
||||
@ -45,10 +39,6 @@ define kMaxSafeInteger = 9007199254740991;
|
||||
# 2^32 - 1
|
||||
define kMaxUint32 = 4294967295;
|
||||
|
||||
# Strict mode flags for passing to %SetProperty
|
||||
define kSloppyMode = 0;
|
||||
define kStrictMode = 1;
|
||||
|
||||
# Native cache ids.
|
||||
define STRING_TO_REGEXP_CACHE_ID = 0;
|
||||
|
||||
@ -108,11 +98,6 @@ macro TO_LENGTH(arg) = (%_ToLength(arg));
|
||||
macro TO_STRING(arg) = (%_ToString(arg));
|
||||
macro TO_NUMBER(arg) = (%_ToNumber(arg));
|
||||
macro TO_OBJECT(arg) = (%_ToObject(arg));
|
||||
macro TO_PRIMITIVE(arg) = (%_ToPrimitive(arg));
|
||||
macro TO_PRIMITIVE_NUMBER(arg) = (%_ToPrimitive_Number(arg));
|
||||
macro TO_PRIMITIVE_STRING(arg) = (%_ToPrimitive_String(arg));
|
||||
macro TO_NAME(arg) = (%_ToName(arg));
|
||||
macro JSON_NUMBER_TO_STRING(arg) = ((%_IsSmi(%IS_VAR(arg)) || arg - arg == 0) ? %_NumberToString(arg) : "null");
|
||||
macro HAS_OWN_PROPERTY(obj, key) = (%_Call(ObjectHasOwnProperty, obj, key));
|
||||
|
||||
# Private names.
|
||||
@ -222,10 +207,6 @@ define NOT_FOUND = -1;
|
||||
# Check whether debug is active.
|
||||
define DEBUG_IS_ACTIVE = (%_DebugIsActive() != 0);
|
||||
|
||||
# SharedFlag equivalents
|
||||
define kNotShared = false;
|
||||
define kShared = true;
|
||||
|
||||
# UseCounters from include/v8.h
|
||||
define kUseAsm = 0;
|
||||
define kBreakIterator = 1;
|
||||
|
@ -131,12 +131,6 @@ function ObjectIsPrototypeOf(V) {
|
||||
}
|
||||
|
||||
|
||||
// ES6 19.1.3.4
|
||||
function ObjectPropertyIsEnumerable(V) {
|
||||
var P = TO_NAME(V);
|
||||
return %PropertyIsEnumerable(TO_OBJECT(this), P);
|
||||
}
|
||||
|
||||
// ES6 7.3.9
|
||||
function GetMethod(obj, p) {
|
||||
var func = obj[p];
|
||||
@ -201,7 +195,7 @@ utils.InstallFunctions(GlobalObject.prototype, DONT_ENUM, [
|
||||
"toLocaleString", ObjectToLocaleString,
|
||||
"valueOf", ObjectValueOf,
|
||||
"isPrototypeOf", ObjectIsPrototypeOf,
|
||||
"propertyIsEnumerable", ObjectPropertyIsEnumerable,
|
||||
// propertyIsEnumerable is added in bootstrapper.cc.
|
||||
// __defineGetter__ is added in bootstrapper.cc.
|
||||
// __lookupGetter__ is added in bootstrapper.cc.
|
||||
// __defineSetter__ is added in bootstrapper.cc.
|
||||
|
@ -330,11 +330,14 @@ RUNTIME_FUNCTION(Runtime_DebugGetInternalProperties) {
|
||||
// Items 2-4 are only filled if the property has either a getter or a setter.
|
||||
RUNTIME_FUNCTION(Runtime_DebugGetPropertyDetails) {
|
||||
HandleScope scope(isolate);
|
||||
|
||||
DCHECK(args.length() == 2);
|
||||
|
||||
DCHECK_EQ(2, args.length());
|
||||
CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0);
|
||||
CONVERT_ARG_HANDLE_CHECKED(Name, name, 1);
|
||||
CONVERT_ARG_HANDLE_CHECKED(Object, name_obj, 1);
|
||||
|
||||
// Convert the {name_obj} to a Name.
|
||||
Handle<Name> name;
|
||||
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, name,
|
||||
Object::ToName(isolate, name_obj));
|
||||
|
||||
// Make sure to set the current context to the context before the debugger was
|
||||
// entered (if the debugger is entered). The reason for switching context here
|
||||
|
@ -564,21 +564,6 @@ RUNTIME_FUNCTION(Runtime_HasProperty) {
|
||||
}
|
||||
|
||||
|
||||
RUNTIME_FUNCTION(Runtime_PropertyIsEnumerable) {
|
||||
HandleScope scope(isolate);
|
||||
DCHECK(args.length() == 2);
|
||||
|
||||
CONVERT_ARG_HANDLE_CHECKED(JSReceiver, object, 0);
|
||||
CONVERT_ARG_HANDLE_CHECKED(Name, key, 1);
|
||||
|
||||
Maybe<PropertyAttributes> maybe =
|
||||
JSReceiver::GetOwnPropertyAttributes(object, key);
|
||||
if (!maybe.IsJust()) return isolate->heap()->exception();
|
||||
if (maybe.FromJust() == ABSENT) return isolate->heap()->false_value();
|
||||
return isolate->heap()->ToBoolean((maybe.FromJust() & DONT_ENUM) == 0);
|
||||
}
|
||||
|
||||
|
||||
RUNTIME_FUNCTION(Runtime_GetOwnPropertyKeys) {
|
||||
HandleScope scope(isolate);
|
||||
DCHECK(args.length() == 2);
|
||||
@ -868,15 +853,6 @@ RUNTIME_FUNCTION(Runtime_ToPrimitive_Number) {
|
||||
}
|
||||
|
||||
|
||||
RUNTIME_FUNCTION(Runtime_ToPrimitive_String) {
|
||||
HandleScope scope(isolate);
|
||||
DCHECK_EQ(1, args.length());
|
||||
CONVERT_ARG_HANDLE_CHECKED(Object, input, 0);
|
||||
RETURN_RESULT_OR_FAILURE(
|
||||
isolate, Object::ToPrimitive(input, ToPrimitiveHint::kString));
|
||||
}
|
||||
|
||||
|
||||
RUNTIME_FUNCTION(Runtime_ToNumber) {
|
||||
HandleScope scope(isolate);
|
||||
DCHECK_EQ(1, args.length());
|
||||
|
@ -388,7 +388,6 @@ namespace internal {
|
||||
F(DeleteProperty_Sloppy, 2, 1) \
|
||||
F(DeleteProperty_Strict, 2, 1) \
|
||||
F(HasProperty, 2, 1) \
|
||||
F(PropertyIsEnumerable, 2, 1) \
|
||||
F(GetOwnPropertyKeys, 2, 1) \
|
||||
F(GetInterceptorInfo, 1, 1) \
|
||||
F(ToFastProperties, 1, 1) \
|
||||
@ -411,7 +410,6 @@ namespace internal {
|
||||
F(ToObject, 1, 1) \
|
||||
F(ToPrimitive, 1, 1) \
|
||||
F(ToPrimitive_Number, 1, 1) \
|
||||
F(ToPrimitive_String, 1, 1) \
|
||||
F(ToNumber, 1, 1) \
|
||||
F(ToInteger, 1, 1) \
|
||||
F(ToLength, 1, 1) \
|
||||
|
@ -22393,7 +22393,7 @@ TEST(AccessCheckThrows) {
|
||||
CheckCorrectThrow("%DeleteProperty_Strict(other, '1')");
|
||||
CheckCorrectThrow("Object.prototype.hasOwnProperty.call(other, 'x')");
|
||||
CheckCorrectThrow("%HasProperty('x', other)");
|
||||
CheckCorrectThrow("%PropertyIsEnumerable(other, 'x')");
|
||||
CheckCorrectThrow("Object.prototype.propertyIsEnumerable(other, 'x')");
|
||||
// PROPERTY_ATTRIBUTES_NONE = 0
|
||||
CheckCorrectThrow("%DefineAccessorPropertyUnchecked("
|
||||
"other, 'x', null, null, 1)");
|
||||
|
@ -5,50 +5,37 @@
|
||||
// Flags: --allow-natives-syntax
|
||||
|
||||
assertEquals("1", %ToName(1));
|
||||
assertEquals("1", %_ToName(1));
|
||||
|
||||
assertEquals("0.5", %ToName(.5));
|
||||
assertEquals("0.5", %_ToName(.5));
|
||||
|
||||
assertEquals("null", %ToName(null));
|
||||
assertEquals("null", %_ToName(null));
|
||||
|
||||
assertEquals("true", %ToName(true));
|
||||
assertEquals("true", %_ToName(true));
|
||||
|
||||
assertEquals("false", %ToName(false));
|
||||
assertEquals("false", %_ToName(false));
|
||||
|
||||
assertEquals("undefined", %ToName(undefined));
|
||||
assertEquals("undefined", %_ToName(undefined));
|
||||
|
||||
assertEquals("random text", %ToName("random text"));
|
||||
assertEquals("random text", %_ToName("random text"));
|
||||
|
||||
assertEquals(Symbol.toPrimitive, %ToName(Symbol.toPrimitive));
|
||||
assertEquals(Symbol.toPrimitive, %_ToName(Symbol.toPrimitive));
|
||||
|
||||
var a = { toString: function() { return "xyz" }};
|
||||
assertEquals("xyz", %ToName(a));
|
||||
assertEquals("xyz", %_ToName(a));
|
||||
|
||||
var b = { valueOf: function() { return 42 }};
|
||||
assertEquals("[object Object]", %ToName(b));
|
||||
assertEquals("[object Object]", %_ToName(b));
|
||||
|
||||
var c = {
|
||||
toString: function() { return "x"},
|
||||
valueOf: function() { return 123 }
|
||||
};
|
||||
assertEquals("x", %ToName(c));
|
||||
assertEquals("x", %_ToName(c));
|
||||
|
||||
var d = {
|
||||
[Symbol.toPrimitive]: function(hint) { return hint }
|
||||
};
|
||||
assertEquals("string", %ToName(d));
|
||||
assertEquals("string", %_ToName(d));
|
||||
|
||||
var e = new Date(0);
|
||||
assertEquals(e.toString(), %ToName(e));
|
||||
assertEquals(e.toString(), %_ToName(e));
|
||||
|
@ -6,75 +6,35 @@
|
||||
|
||||
assertEquals(1, %ToPrimitive(1));
|
||||
assertEquals(1, %ToPrimitive_Number(1));
|
||||
assertEquals(1, %ToPrimitive_String(1));
|
||||
assertEquals(1, %_ToPrimitive(1));
|
||||
assertEquals(1, %_ToPrimitive_Number(1));
|
||||
assertEquals(1, %_ToPrimitive_String(1));
|
||||
|
||||
assertEquals(.5, %ToPrimitive(.5));
|
||||
assertEquals(.5, %ToPrimitive_Number(.5));
|
||||
assertEquals(.5, %ToPrimitive_String(.5));
|
||||
assertEquals(.5, %_ToPrimitive(.5));
|
||||
assertEquals(.5, %_ToPrimitive_Number(.5));
|
||||
assertEquals(.5, %_ToPrimitive_String(.5));
|
||||
|
||||
assertEquals(null, %ToPrimitive(null));
|
||||
assertEquals(null, %ToPrimitive_Number(null));
|
||||
assertEquals(null, %ToPrimitive_String(null));
|
||||
assertEquals(null, %_ToPrimitive(null));
|
||||
assertEquals(null, %_ToPrimitive_Number(null));
|
||||
assertEquals(null, %_ToPrimitive_String(null));
|
||||
|
||||
assertEquals(true, %ToPrimitive(true));
|
||||
assertEquals(true, %ToPrimitive_Number(true));
|
||||
assertEquals(true, %ToPrimitive_String(true));
|
||||
assertEquals(true, %_ToPrimitive(true));
|
||||
assertEquals(true, %_ToPrimitive_Number(true));
|
||||
assertEquals(true, %_ToPrimitive_String(true));
|
||||
|
||||
assertEquals(false, %ToPrimitive(false));
|
||||
assertEquals(false, %ToPrimitive_Number(false));
|
||||
assertEquals(false, %ToPrimitive_String(false));
|
||||
assertEquals(false, %_ToPrimitive(false));
|
||||
assertEquals(false, %_ToPrimitive_Number(false));
|
||||
assertEquals(false, %_ToPrimitive_String(false));
|
||||
|
||||
assertEquals(undefined, %ToPrimitive(undefined));
|
||||
assertEquals(undefined, %ToPrimitive_Number(undefined));
|
||||
assertEquals(undefined, %ToPrimitive_String(undefined));
|
||||
assertEquals(undefined, %_ToPrimitive(undefined));
|
||||
assertEquals(undefined, %_ToPrimitive_Number(undefined));
|
||||
assertEquals(undefined, %_ToPrimitive_String(undefined));
|
||||
|
||||
assertEquals("random text", %ToPrimitive("random text"));
|
||||
assertEquals("random text", %ToPrimitive_Number("random text"));
|
||||
assertEquals("random text", %ToPrimitive_String("random text"));
|
||||
assertEquals("random text", %_ToPrimitive("random text"));
|
||||
assertEquals("random text", %_ToPrimitive_Number("random text"));
|
||||
assertEquals("random text", %_ToPrimitive_String("random text"));
|
||||
|
||||
assertEquals(Symbol.toPrimitive, %ToPrimitive(Symbol.toPrimitive));
|
||||
assertEquals(Symbol.toPrimitive, %ToPrimitive_Number(Symbol.toPrimitive));
|
||||
assertEquals(Symbol.toPrimitive, %ToPrimitive_String(Symbol.toPrimitive));
|
||||
assertEquals(Symbol.toPrimitive, %_ToPrimitive(Symbol.toPrimitive));
|
||||
assertEquals(Symbol.toPrimitive, %_ToPrimitive_Number(Symbol.toPrimitive));
|
||||
assertEquals(Symbol.toPrimitive, %_ToPrimitive_String(Symbol.toPrimitive));
|
||||
|
||||
var a = { toString: function() { return "xyz" }};
|
||||
assertEquals("xyz", %ToPrimitive(a));
|
||||
assertEquals("xyz", %ToPrimitive_Number(a));
|
||||
assertEquals("xyz", %ToPrimitive_String(a));
|
||||
assertEquals("xyz", %_ToPrimitive(a));
|
||||
assertEquals("xyz", %_ToPrimitive_Number(a));
|
||||
assertEquals("xyz", %_ToPrimitive_String(a));
|
||||
|
||||
var b = { valueOf: function() { return 42 }};
|
||||
assertEquals(42, %ToPrimitive(b));
|
||||
assertEquals(42, %ToPrimitive_Number(b));
|
||||
assertEquals("[object Object]", %ToPrimitive_String(b));
|
||||
assertEquals(42, %_ToPrimitive(b));
|
||||
assertEquals(42, %_ToPrimitive_Number(b));
|
||||
assertEquals("[object Object]", %_ToPrimitive_String(b));
|
||||
|
||||
var c = {
|
||||
toString: function() { return "x"},
|
||||
@ -82,25 +42,13 @@ var c = {
|
||||
};
|
||||
assertEquals(123, %ToPrimitive(c));
|
||||
assertEquals(123, %ToPrimitive_Number(c));
|
||||
assertEquals("x", %ToPrimitive_String(c));
|
||||
assertEquals(123, %_ToPrimitive(c));
|
||||
assertEquals(123, %_ToPrimitive_Number(c));
|
||||
assertEquals("x", %_ToPrimitive_String(c));
|
||||
|
||||
var d = {
|
||||
[Symbol.toPrimitive]: function(hint) { return hint }
|
||||
};
|
||||
assertEquals("default", %ToPrimitive(d));
|
||||
assertEquals("number", %ToPrimitive_Number(d));
|
||||
assertEquals("string", %ToPrimitive_String(d));
|
||||
assertEquals("default", %_ToPrimitive(d));
|
||||
assertEquals("number", %_ToPrimitive_Number(d));
|
||||
assertEquals("string", %_ToPrimitive_String(d));
|
||||
|
||||
var e = new Date(0);
|
||||
assertEquals(e.toString(), %ToPrimitive(e));
|
||||
assertEquals(0, %ToPrimitive_Number(e));
|
||||
assertEquals(e.toString(), %ToPrimitive_String(e));
|
||||
assertEquals(e.toString(), %_ToPrimitive(e));
|
||||
assertEquals(0, %_ToPrimitive_Number(e));
|
||||
assertEquals(e.toString(), %_ToPrimitive_String(e));
|
||||
|
@ -50,5 +50,5 @@ assertEquals("string", %ToString(d));
|
||||
assertEquals("string", %_ToString(d));
|
||||
|
||||
var e = new Date(0);
|
||||
assertEquals(e.toString(), %ToName(e));
|
||||
assertEquals(e.toString(), %_ToName(e));
|
||||
assertEquals(e.toString(), %ToString(e));
|
||||
assertEquals(e.toString(), %_ToString(e));
|
||||
|
Loading…
Reference in New Issue
Block a user