Changeset 171278 in webkit
- Timestamp:
- Jul 20, 2014 9:16:57 AM (10 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r171263 r171278 1 2014-07-20 Diego Pino Garcia <dpino@igalia.com> 2 3 ES6: Implement Math.sign() 4 https://bugs.webkit.org/show_bug.cgi?id=134980 5 6 Reviewed by Darin Adler. 7 8 * js/script-tests/Object-getOwnPropertyNames.js: 9 * js/script-tests/math.js: 10 1 11 2014-07-19 Carlos Alberto Lopez Perez <clopez@igalia.com> 2 12 -
trunk/LayoutTests/js/Object-getOwnPropertyNames-expected.txt
r167797 r171278 59 59 PASS getSortedOwnPropertyNames(Error) is ['length', 'name', 'prototype'] 60 60 PASS getSortedOwnPropertyNames(Error.prototype) is ['constructor', 'message', 'name', 'toString'] 61 PASS getSortedOwnPropertyNames(Math) is ['E','LN10','LN2','LOG10E','LOG2E','PI','SQRT1_2','SQRT2','abs','acos','acosh','asin','asinh','atan','atan2','atanh','cbrt','ceil','cos','cosh','exp','expm1','floor','fround','hypot','imul','log','log10','log1p','log2','max','min','pow','random','round','si n','sinh','sqrt','tan','tanh','trunc']61 PASS getSortedOwnPropertyNames(Math) is ['E','LN10','LN2','LOG10E','LOG2E','PI','SQRT1_2','SQRT2','abs','acos','acosh','asin','asinh','atan','atan2','atanh','cbrt','ceil','cos','cosh','exp','expm1','floor','fround','hypot','imul','log','log10','log1p','log2','max','min','pow','random','round','sign','sin','sinh','sqrt','tan','tanh','trunc'] 62 62 PASS getSortedOwnPropertyNames(JSON) is ['parse', 'stringify'] 63 63 PASS globalPropertyNames.indexOf('NaN') != -1 is true -
trunk/LayoutTests/js/math-expected.txt
r165795 r171278 182 182 PASS Math.round(Infinity) is Infinity 183 183 PASS Math.round(-Infinity) is -Infinity 184 PASS Math.sign(NaN) is NaN 185 PASS Math.sign('string') is NaN 186 PASS Math.sign([1, 2, 3]) is NaN 187 PASS Math.sign({}) is NaN 188 PASS Math.sign(0) is 0 189 PASS Math.sign(-0) is -0 190 PASS Math.sign(-1) is -1 191 PASS Math.sign(1) is 1 192 PASS Math.sign(0.1) is 1 193 PASS Math.sign(-0.1) is -1 194 PASS Math.sign(10000) is 1 195 PASS Math.sign(-10000) is -1 196 PASS Math.sign(Number.MIN_VALUE) is 1 197 PASS Math.sign(-Number.MIN_VALUE) is -1 198 PASS Math.sign(Number.MAX_VALUE) is 1 199 PASS Math.sign(-Number.MAX_VALUE) is -1 200 PASS Math.sign(Infinity) is 1 201 PASS Math.sign(-Infinity) is -1 184 202 PASS Math.sin(NaN) is NaN 185 203 PASS Math.sin(0) is 0 -
trunk/LayoutTests/js/script-tests/Object-getOwnPropertyNames.js
r167797 r171278 67 67 "Error": "['length', 'name', 'prototype']", 68 68 "Error.prototype": "['constructor', 'message', 'name', 'toString']", 69 "Math": "['E','LN10','LN2','LOG10E','LOG2E','PI','SQRT1_2','SQRT2','abs','acos','acosh','asin','asinh','atan','atan2','atanh','cbrt','ceil','cos','cosh','exp','expm1','floor','fround','hypot','imul','log','log10','log1p','log2','max','min','pow','random','round','si n','sinh','sqrt','tan','tanh','trunc']",69 "Math": "['E','LN10','LN2','LOG10E','LOG2E','PI','SQRT1_2','SQRT2','abs','acos','acosh','asin','asinh','atan','atan2','atanh','cbrt','ceil','cos','cosh','exp','expm1','floor','fround','hypot','imul','log','log10','log1p','log2','max','min','pow','random','round','sign','sin','sinh','sqrt','tan','tanh','trunc']", 70 70 "JSON": "['parse', 'stringify']" 71 71 }; -
trunk/LayoutTests/js/script-tests/math.js
r165795 r171278 255 255 shouldBe("Math.round(-Infinity)", "-Infinity"); 256 256 257 shouldBe("Math.sign(NaN)", "NaN"); 258 shouldBe("Math.sign('string')", "NaN"); 259 shouldBe("Math.sign([1, 2, 3])", "NaN"); 260 shouldBe("Math.sign({})", "NaN"); 261 shouldBe("Math.sign(0)", "0"); 262 shouldBe("Math.sign(-0)", "-0"); 263 shouldBe("Math.sign(-1)", "-1"); 264 shouldBe("Math.sign(1)", "1"); 265 shouldBe("Math.sign(0.1)", "1"); 266 shouldBe("Math.sign(-0.1)", "-1"); 267 shouldBe("Math.sign(10000)", "1"); 268 shouldBe("Math.sign(-10000)", "-1"); 269 shouldBe("Math.sign(Number.MIN_VALUE)", "1"); 270 shouldBe("Math.sign(-Number.MIN_VALUE)", "-1"); 271 shouldBe("Math.sign(Number.MAX_VALUE)", "1"); 272 shouldBe("Math.sign(-Number.MAX_VALUE)", "-1"); 273 shouldBe("Math.sign(Infinity)", "1"); 274 shouldBe("Math.sign(-Infinity)", "-1"); 275 257 276 shouldBe("Math.sin(NaN)", "NaN"); 258 277 shouldBe("Math.sin(0)", "0"); -
trunk/Source/JavaScriptCore/ChangeLog
r171241 r171278 1 2014-07-20 Diego Pino Garcia <dpino@igalia.com> 2 3 ES6: Implement Math.sign() 4 https://bugs.webkit.org/show_bug.cgi?id=134980 5 6 Reviewed by Darin Adler. 7 8 * runtime/MathObject.cpp: 9 (JSC::MathObject::finishCreation): 10 (JSC::mathProtoFuncSign): 11 1 12 2014-07-18 Filip Pizlo <fpizlo@apple.com> 2 13 -
trunk/Source/JavaScriptCore/runtime/MathObject.cpp
r167394 r171278 62 62 static EncodedJSValue JSC_HOST_CALL mathProtoFuncRandom(ExecState*); 63 63 static EncodedJSValue JSC_HOST_CALL mathProtoFuncRound(ExecState*); 64 static EncodedJSValue JSC_HOST_CALL mathProtoFuncSign(ExecState*); 64 65 static EncodedJSValue JSC_HOST_CALL mathProtoFuncSin(ExecState*); 65 66 static EncodedJSValue JSC_HOST_CALL mathProtoFuncSinh(ExecState*); … … 121 122 putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier(&vm, "random"), 0, mathProtoFuncRandom, NoIntrinsic, DontEnum | Function); 122 123 putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier(&vm, "round"), 1, mathProtoFuncRound, RoundIntrinsic, DontEnum | Function); 124 putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier(&vm, "sign"), 1, mathProtoFuncSign, NoIntrinsic, DontEnum | Function); 123 125 putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier(&vm, "sin"), 1, mathProtoFuncSin, SinIntrinsic, DontEnum | Function); 124 126 putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier(&vm, "sinh"), 1, mathProtoFuncSinh, NoIntrinsic, DontEnum | Function); … … 302 304 double integer = ceil(arg); 303 305 return JSValue::encode(jsNumber(integer - (integer - arg > 0.5))); 306 } 307 308 EncodedJSValue JSC_HOST_CALL mathProtoFuncSign(ExecState* exec) 309 { 310 double arg = exec->argument(0).toNumber(exec); 311 if (std::isnan(arg)) 312 return JSValue::encode(jsNaN()); 313 if (!arg) 314 return JSValue::encode(std::signbit(arg) ? jsNumber(-0.0) : jsNumber(0)); 315 return JSValue::encode(jsNumber(std::signbit(arg) ? -1 : 1)); 304 316 } 305 317
Note: See TracChangeset
for help on using the changeset viewer.