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
Andrew Kesterson a428b905da Added the ability to parse commands as well as expressions.
Added basic PRINT and REM commands.
Added solver tests which had been around for a while and not committed.
All execution is still immediate mode.
2024-05-06 16:57:13 -04:00

36 lines
924 B
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;
return 0;
}