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
def test_CreateRangeError_01(realm): re = ecmascript.CreateRangeError("test range error") assert ecmascript.isObject(re) assert ecmascript.ToString(re) == "RangeError: test range error"
def test_CreateTypeError_01(realm): re = ecmascript.CreateTypeError("test type error") assert ecmascript.isObject(re) assert ecmascript.ToString(re) == "TypeError: test type error"
def test_CreateSyntaxError_01(realm): re = ecmascript.CreateSyntaxError("test syntax error") assert ecmascript.isObject(re) assert ecmascript.ToString(re) == "SyntaxError: test syntax error"
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"