Exemplo n.º 1
0
def test_StringGetOwnProperty_02(realm):
    # Check the props for the character positions
    proto = realm.intrinsics["%ObjectPrototype%"]
    test_str = "I am a test string."
    str = e.StringCreate(test_str, proto)

    for idx, ch in enumerate(test_str):
        desc = e.StringGetOwnProperty(str, e.ToString(idx))
        result = (desc.value, desc.writable, desc.enumerable, desc.configurable)
        expected = (ch, False, True, False)
        assert result == expected
Exemplo n.º 2
0
def test_CreateRangeError_01(realm):
    re = ecmascript.CreateRangeError("test range error")

    assert ecmascript.isObject(re)
    assert ecmascript.ToString(re) == "RangeError: test range error"
Exemplo n.º 3
0
def test_CreateTypeError_01(realm):
    re = ecmascript.CreateTypeError("test type error")

    assert ecmascript.isObject(re)
    assert ecmascript.ToString(re) == "TypeError: test type error"
Exemplo n.º 4
0
def test_CreateSyntaxError_01(realm):
    re = ecmascript.CreateSyntaxError("test syntax error")

    assert ecmascript.isObject(re)
    assert ecmascript.ToString(re) == "SyntaxError: test syntax error"
Exemplo n.º 5
0
def test_CreateErrorObject_02(realm, intrinsic_name):
    rv = ecmascript.CreateErrorObject("test message", f"%{intrinsic_name}%")
    assert ecmascript.isObject(rv)
    assert ecmascript.ToString(rv) == f"{intrinsic_name}: test message"