fix: change String#contains return type from numeric to boolean
Replace NUM_VAL and integer literals with TRUE_VAL, FALSE_VAL, and BOOL_VAL in the string_contains primitive implementation, and update the test expectations from 1/0 to true/false accordingly.
This commit is contained in:
+2
-3
@@ -176,10 +176,9 @@ DEF_PRIMITIVE(string_contains)
|
||||
const char* search = AS_CSTRING(args[1]);
|
||||
|
||||
// Corner case, the empty string contains the empty string.
|
||||
if (strlen(string) == 0 && strlen(search) == 0) return NUM_VAL(1);
|
||||
if (strlen(string) == 0 && strlen(search) == 0) return TRUE_VAL;
|
||||
|
||||
// TODO(bob): Return bool.
|
||||
return NUM_VAL(strstr(string, search) != NULL);
|
||||
return BOOL_VAL(strstr(string, search) != NULL);
|
||||
}
|
||||
|
||||
DEF_PRIMITIVE(string_count)
|
||||
|
||||
Reference in New Issue
Block a user