More tests for primitives.

This commit is contained in:
Bob Nystrom
2013-10-28 06:53:51 -07:00
parent f5d9908346
commit db14c531b8
5 changed files with 20 additions and 1 deletions
+3
View File
@@ -35,6 +35,9 @@ DEF_PRIMITIVE(string_contains)
// TODO(bob): Check type of arg first!
const char* search = ((ObjString*)args[1])->value;
// Corner case, the empty string contains the empty string.
if (strlen(string) == 0 && strlen(search) == 0) return (Value)makeNum(1);
// TODO(bob): Return bool.
return (Value)makeNum(strstr(string, search) != NULL);
}