Test string concatenation.
This commit is contained in:
+1
-4
@@ -595,7 +595,6 @@ DEF_NATIVE(num_minus)
|
|||||||
DEF_NATIVE(num_plus)
|
DEF_NATIVE(num_plus)
|
||||||
{
|
{
|
||||||
if (!validateNum(vm, args, 1, "Right operand")) return PRIM_ERROR;
|
if (!validateNum(vm, args, 1, "Right operand")) return PRIM_ERROR;
|
||||||
// TODO: Handle coercion to string if RHS is a string.
|
|
||||||
RETURN_NUM(AS_NUM(args[0]) + AS_NUM(args[1]));
|
RETURN_NUM(AS_NUM(args[0]) + AS_NUM(args[1]));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -845,9 +844,7 @@ DEF_NATIVE(string_toString)
|
|||||||
|
|
||||||
DEF_NATIVE(string_plus)
|
DEF_NATIVE(string_plus)
|
||||||
{
|
{
|
||||||
if (!IS_STRING(args[1])) RETURN_NULL;
|
if (!validateString(vm, args, 1, "Right operand")) return PRIM_ERROR;
|
||||||
// TODO: Handle coercion to string of RHS.
|
|
||||||
|
|
||||||
RETURN_OBJ(wrenStringConcat(vm, AS_CSTRING(args[0]), AS_CSTRING(args[1])));
|
RETURN_OBJ(wrenStringConcat(vm, AS_CSTRING(args[0]), AS_CSTRING(args[1])));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
IO.print("a" + "b") // expect: ab
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
IO.print("a" + 123) // expect runtime error: Right operand must be a string.
|
||||||
Reference in New Issue
Block a user