Skip to content
This repository was archived by the owner on Nov 11, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions tests/streq.porth
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
include "std.porth"

macro debug_streq
"\"" puts
over dup strlen swap puts
"\" == \"" puts
dup dup strlen swap puts
"\" is " puts
streq print
end

macro str_as_ptr swap drop end


"hello\0" str_as_ptr
"hello\0" str_as_ptr
debug_streq

"hello\0" str_as_ptr
"world\0" str_as_ptr
debug_streq

"hello\0" str_as_ptr
"\0" str_as_ptr
debug_streq

"\0" str_as_ptr
"world\0" str_as_ptr
debug_streq

"\0" str_as_ptr
"\0" str_as_ptr
debug_streq
13 changes: 13 additions & 0 deletions tests/streq.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
:i argc 0
:b stdin 0

:i returncode 0
:b stdout 100
"hello" == "hello" is 1
"hello" == "world" is 0
"hello" == "" is 0
"" == "world" is 0
"" == "" is 1

:b stderr 0

14 changes: 14 additions & 0 deletions tests/strlen.porth
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
include "std.porth"

macro debug_strlen
"strlen(\"" puts
dup dup strlen swap puts
"\") == " puts
strlen print
end

macro str_as_ptr swap drop end


"\0" str_as_ptr debug_strlen
"hello\0" str_as_ptr debug_strlen
10 changes: 10 additions & 0 deletions tests/strlen.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
:i argc 0
:b stdin 0

:i returncode 0
:b stdout 37
strlen("") == 0
strlen("hello") == 5

:b stderr 0