Add test for global variables

This commit is contained in:
Joshua Suskalo 2022-11-29 13:43:06 -06:00
parent 12b7661295
commit 4c60ff5085
No known key found for this signature in database
GPG key ID: 9B6BA586EFF1B9F0
2 changed files with 6 additions and 1 deletions

View file

@ -26,7 +26,7 @@ CString upcall_test(StringFactory fun) {
return fun();
}
static int counter = 0;
int counter = 0;
static char* responses[] = { "Hello, world!", "Goodbye friend.", "co'oi prenu" };

View file

@ -44,3 +44,8 @@
{:a \x
:x 3.14
:y 42.0})))
(t/deftest static-variables-are-mutable
(ffi/freset! (ffi/static-variable "counter" ::mem/int) 1)
(t/is (= ((ffi/cfn "get_string1" [] ::mem/c-string))
"Goodbye friend.")))