This repository has been archived on 2026-05-18. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
piquant/tests/basic_solver.c

49 lines
1.4 KiB
C

#include "types.h"
#include "basic.h"
#include "string.h"
#include <stdio.h>
int main(void)
{
basic_expr expr;
basic_variable result;
result.flags = 0;
expr.type = BASIC_OPTP_ADD;
expr.lval_type = BASIC_LVAL_CONST_INT;
expr.lval.i = 1;
expr.rval_type = BASIC_RVAL_CONST_INT;
expr.rval.i = 1;
basic_solve_expr(&expr, &result);
if ( basic_errno != 0 ) return 2;
if ( result.flags != (BASIC_VARFLAG_INIT | BASIC_VARFLAG_TINT) ) return 3;
if ( result.value.i != 2 ) return 4;
expr.type = BASIC_OPTP_NONE;
expr.lval_type = BASIC_LVAL_CONST_INT;
expr.lval.i = 1;
expr.rval_type = BASIC_RVAL_NONE;
memset(&result, 0x00, sizeof(basic_variable));
basic_solve_expr(&expr, &result);
if ( basic_errno != 0 ) return 5;
if ( result.flags != (BASIC_VARFLAG_INIT | BASIC_VARFLAG_TINT) ) return 6;
if ( result.value.i != 1 ) return 7;
expr.type = BASIC_OPTP_STOR;
expr.lval_type = BASIC_LVAL_CONST_INT;
expr.rval_type = BASIC_RVAL_PTR;
expr.lval.i = 10;
expr.rval.ptr = " REM ignore me";
memset(&result, 0x00, sizeof(basic_variable));
basic_solve_expr(&expr, &result);
if ( basic_errno != 0 ) return 8;
if ( result.flags != (BASIC_VARFLAG_INIT | BASIC_VARFLAG_TSTR) ) return 9;
if ( result.value.ptr == NULL ) return 10;
if ( strcmp((char *)&basic_memory_lines[10], expr.rval.ptr) != 0 ) return 11;
return 0;
}