mirror of
https://github.com/urbit/shrub.git
synced 2024-12-23 19:05:48 +03:00
test: move _test_lily into noun_tests
This commit is contained in:
parent
af1f2da161
commit
5825cbde71
pkg/urbit/tests
@ -1,68 +0,0 @@
|
||||
#include "all.h"
|
||||
#include "ur/ur.h"
|
||||
#include "vere/ivory.h"
|
||||
#include "vere/vere.h"
|
||||
|
||||
/* _setup(): prepare for tests.
|
||||
*/
|
||||
static void
|
||||
_setup(void)
|
||||
{
|
||||
c3_d len_d = u3_Ivory_pill_len;
|
||||
c3_y* byt_y = u3_Ivory_pill;
|
||||
u3_cue_xeno* sil_u;
|
||||
u3_weak pil;
|
||||
|
||||
u3C.wag_w |= u3o_hashless;
|
||||
u3m_boot_lite();
|
||||
sil_u = u3s_cue_xeno_init_with(ur_fib27, ur_fib28);
|
||||
if ( u3_none == (pil = u3s_cue_xeno_with(sil_u, len_d, byt_y)) ) {
|
||||
printf("*** fail _setup 1\n");
|
||||
exit(1);
|
||||
}
|
||||
u3s_cue_xeno_done(sil_u);
|
||||
if ( c3n == u3v_boot_lite(pil) ) {
|
||||
printf("*** fail _setup 2\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
/* _test_lily(): test small noun parsing.
|
||||
*/
|
||||
static void
|
||||
_test_lily()
|
||||
{
|
||||
c3_l lit_l;
|
||||
c3_w big_w[] = {0, 0, 1};
|
||||
u3_noun big = u3i_words(3, big_w);
|
||||
u3_noun cod = u3dc("scot", c3__uv, big);
|
||||
|
||||
if ( c3y == u3v_lily(c3__uv, cod, &lit_l) ) {
|
||||
printf("*** fail _test_lily-1\n");
|
||||
exit(1);
|
||||
}
|
||||
cod = u3dc("scot", c3__ud, 0x7fffffff);
|
||||
if ( (c3n == u3v_lily(c3__ud, cod, &lit_l)) ||
|
||||
(0x7fffffff != lit_l) ) {
|
||||
printf("*** fail _test_lily-2a\n");
|
||||
exit(1);
|
||||
}
|
||||
cod = u3dc("scot", c3__ux, u3i_word(0x80000000));
|
||||
if ( c3y == u3v_lily(c3__ux, cod, &lit_l) ) {
|
||||
printf("*** fail _test_lily-2b\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
/* main(): run all test cases.
|
||||
*/
|
||||
int
|
||||
main(int argc, char* argv[])
|
||||
{
|
||||
_setup();
|
||||
|
||||
_test_lily();
|
||||
|
||||
fprintf(stderr, "test boot: ok\n");
|
||||
return 0;
|
||||
}
|
@ -1,4 +1,7 @@
|
||||
#include "all.h"
|
||||
#include "ur/ur.h"
|
||||
#include "vere/ivory.h"
|
||||
#include "vere/vere.h"
|
||||
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
@ -8,8 +11,23 @@
|
||||
static void
|
||||
_setup(void)
|
||||
{
|
||||
u3m_init();
|
||||
u3m_pave(c3y);
|
||||
c3_d len_d = u3_Ivory_pill_len;
|
||||
c3_y* byt_y = u3_Ivory_pill;
|
||||
u3_cue_xeno* sil_u;
|
||||
u3_weak pil;
|
||||
|
||||
u3C.wag_w |= u3o_hashless;
|
||||
u3m_boot_lite();
|
||||
sil_u = u3s_cue_xeno_init_with(ur_fib27, ur_fib28);
|
||||
if ( u3_none == (pil = u3s_cue_xeno_with(sil_u, len_d, byt_y)) ) {
|
||||
printf("*** fail _setup 1\n");
|
||||
exit(1);
|
||||
}
|
||||
u3s_cue_xeno_done(sil_u);
|
||||
if ( c3n == u3v_boot_lite(pil) ) {
|
||||
printf("*** fail _setup 2\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
/* _util_rand_string(): dynamically allocated len_w random string
|
||||
@ -1634,6 +1652,33 @@ _test_nvm_stack()
|
||||
#endif
|
||||
}
|
||||
|
||||
/* _test_lily(): test small noun parsing.
|
||||
*/
|
||||
static void
|
||||
_test_lily()
|
||||
{
|
||||
c3_l lit_l;
|
||||
c3_w big_w[] = {0, 0, 1};
|
||||
u3_noun big = u3i_words(3, big_w);
|
||||
u3_noun cod = u3dc("scot", c3__uv, big);
|
||||
|
||||
if ( c3y == u3v_lily(c3__uv, cod, &lit_l) ) {
|
||||
printf("*** fail _test_lily-1\n");
|
||||
exit(1);
|
||||
}
|
||||
cod = u3dc("scot", c3__ud, 0x7fffffff);
|
||||
if ( (c3n == u3v_lily(c3__ud, cod, &lit_l)) ||
|
||||
(0x7fffffff != lit_l) ) {
|
||||
printf("*** fail _test_lily-2a\n");
|
||||
exit(1);
|
||||
}
|
||||
cod = u3dc("scot", c3__ux, u3i_word(0x80000000));
|
||||
if ( c3y == u3v_lily(c3__ux, cod, &lit_l) ) {
|
||||
printf("*** fail _test_lily-2b\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
/* main(): run all test cases.
|
||||
*/
|
||||
int
|
||||
@ -1653,6 +1698,7 @@ main(int argc, char* argv[])
|
||||
_test_cells_complex();
|
||||
_test_u3r_at();
|
||||
_test_nvm_stack();
|
||||
_test_lily();
|
||||
|
||||
fprintf(stderr, "test_noun: ok\n");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user