blob: 644dc410e4f09ef3bebc971bb34e3165fd624532 [file] [log] [blame]
Tests for .valueAsNumber with <input type=range>.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS valueAsNumberFor("0") is 0
PASS valueAsNumberFor("10") is 10
PASS valueAsNumberFor("01") is 1
PASS valueAsNumberFor("-0") is 0
PASS valueAsNumberFor("-1.2") is 0
PASS valueAsNumberFor("0.2") is 0
PASS valueAsNumberFor(".2") is 0
PASS valueAsNumberFor("1.2E10") is 100
PASS valueAsNumberFor("1.2E-10") is 0
PASS valueAsNumberFor("1.2E+10") is 100
PASS valueAsNumberFor("123456789012345678901234567890123456789") is 100
PASS valueAsNumberFor("0.12345678901234567890123456789012345678901234567890") is 0
valueAsNumber for invalid string values:
PASS valueAsNumberFor("") is 50
PASS valueAsNumberFor("abc") is 50
PASS valueAsNumberFor("0xff") is 50
PASS valueAsNumberFor("+1") is 50
PASS valueAsNumberFor(" 10") is 50
PASS valueAsNumberFor("10 ") is 50
PASS valueAsNumberFor("1E") is 50
PASS valueAsNumberFor("NaN") is 50
PASS valueAsNumberFor("nan") is 50
PASS valueAsNumberFor("Inf") is 50
PASS valueAsNumberFor("inf") is 50
PASS valueAsNumberFor("Infinity") is 50
PASS valueAsNumberFor("infinity") is 50
Too huge exponent to support
PASS valueAsNumberFor("1.2E65535") is 50
Tests for the valueAsNumber setter:
PASS setValueAsNumberAndGetValue(0) is "0"
PASS setValueAsNumberAndGetValue(10) is "10"
PASS setValueAsNumberAndGetValue(01) is "1"
PASS setValueAsNumberAndGetValue(-0) is "0"
PASS setValueAsNumberAndGetValue(-1.2) is "0"
PASS setValueAsNumberAndGetValue(1.2e10) is "100"
PASS setValueAsNumberAndGetValue(1.2e-10) is "0"
PASS setValueAsNumberAndGetValue(1.2345678901234567e+38) is "100"
Tests to set invalid values to valueAsNumber:
PASS setValueAsNumberAndGetValue(null) is "0"
PASS setValueAsNumberAndGetValue("foo") threw exception NotSupportedError: The operation is not supported..
PASS setValueAsNumberAndGetValue(NaN) threw exception NotSupportedError: The operation is not supported..
PASS setValueAsNumberAndGetValue(Number.NaN) threw exception NotSupportedError: The operation is not supported..
PASS setValueAsNumberAndGetValue(Infinity) threw exception NotSupportedError: The operation is not supported..
PASS setValueAsNumberAndGetValue(Number.POSITIVE_INFINITY) threw exception NotSupportedError: The operation is not supported..
PASS setValueAsNumberAndGetValue(Number.NEGATIVE_INFINITY) threw exception NotSupportedError: The operation is not supported..
PASS successfullyParsed is true
TEST COMPLETE