Compare commits
No commits in common. "35322de3ac986038899d6cd3c69d22783f3eff75" and "9a9e5cd3e001acc2b49c41c10fe2b47c92b356df" have entirely different histories.
35322de3ac
...
9a9e5cd3e0
7
Makefile
7
Makefile
@ -15,7 +15,6 @@ CC = clang
|
|||||||
LINK = clang
|
LINK = clang
|
||||||
CFLAGS = -Wall -DDBG -ggdb
|
CFLAGS = -Wall -DDBG -ggdb
|
||||||
LDFLAGS = -lm
|
LDFLAGS = -lm
|
||||||
BATS = bats
|
|
||||||
|
|
||||||
SRC_FILES = $(wildcard $(SRC_DIR)/*.c)
|
SRC_FILES = $(wildcard $(SRC_DIR)/*.c)
|
||||||
OBJ_FILES = $(patsubst $(SRC_DIR)/%.c, $(OBJ_DIR)/%.o, $(SRC_FILES))
|
OBJ_FILES = $(patsubst $(SRC_DIR)/%.c, $(OBJ_DIR)/%.o, $(SRC_FILES))
|
||||||
@ -28,7 +27,6 @@ UNITY_OBJ = $(TEST_BUILD_DIR)/unity.o
|
|||||||
TEST_SRC_FILES = $(wildcard $(TEST_DIR)/*.c)
|
TEST_SRC_FILES = $(wildcard $(TEST_DIR)/*.c)
|
||||||
TEST_OBJ_FILES = $(patsubst $(TEST_DIR)/%.c, $(TEST_OBJ_DIR)/%.o, $(TEST_SRC_FILES))
|
TEST_OBJ_FILES = $(patsubst $(TEST_DIR)/%.c, $(TEST_OBJ_DIR)/%.o, $(TEST_SRC_FILES))
|
||||||
TEST_BIN_FILES = $(patsubst $(TEST_DIR)/%.c, $(TEST_BUILD_DIR)/%.out, $(TEST_SRC_FILES))
|
TEST_BIN_FILES = $(patsubst $(TEST_DIR)/%.c, $(TEST_BUILD_DIR)/%.out, $(TEST_SRC_FILES))
|
||||||
TEST_VAL_DIR = $(TEST_DIR)/validation
|
|
||||||
|
|
||||||
RESETCOLOR = \033[0m
|
RESETCOLOR = \033[0m
|
||||||
WHITE = $(RESETCOLOR)\033[37m
|
WHITE = $(RESETCOLOR)\033[37m
|
||||||
@ -89,11 +87,8 @@ $(TEST_BUILD_DIR)/test_%.out: $(TEST_OBJ_DIR)/test_%.o $(OBJ_DIR)/%.o $(UNITY_OB
|
|||||||
|
|
||||||
# Run the test files.
|
# Run the test files.
|
||||||
test: $(TEST_BIN_FILES)
|
test: $(TEST_BIN_FILES)
|
||||||
@ echo -e "$(WHITE_BOLD)Running unit tests...$(RESETCOLOR)"
|
@ echo -e "$(WHITE_BOLD)Running tests...$(RESETCOLOR)"
|
||||||
for test in $<; do ./$${test}; done
|
for test in $<; do ./$${test}; done
|
||||||
@ echo -e "$(WHITE_BOLD)Running validation tests...$(RESETCOLOR)"
|
|
||||||
$(BATS) $(TEST_VAL_DIR)
|
|
||||||
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@ echo -e "$(WHITE_BOLD)Cleaning up...$(RESETCOLOR)"
|
@ echo -e "$(WHITE_BOLD)Cleaning up...$(RESETCOLOR)"
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "include/ast.h"
|
#include "include/ast.h"
|
||||||
#include "include/dstr.h"
|
#include "include/dstr.h"
|
||||||
@ -19,12 +18,6 @@ extern int yyparse();
|
|||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
|
|
||||||
if (argc - 1 && strlen(argv[1]) > 0 && (inp = argv[1]) && !yyparse()) {
|
|
||||||
log_dbg("Parsed successfully!\n");
|
|
||||||
exec_print(exec_expr(root));
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
Dstr* ln = dstr_init();
|
Dstr* ln = dstr_init();
|
||||||
char c;
|
char c;
|
||||||
|
@ -1,59 +0,0 @@
|
|||||||
#!/usr/bin/env bats
|
|
||||||
|
|
||||||
bin() { ./scl.out $1 | tail -n1; }
|
|
||||||
|
|
||||||
@test "simple addition" {
|
|
||||||
run bin "1+1"
|
|
||||||
[ "$output" = "= 2.000000" ]
|
|
||||||
|
|
||||||
run bin "-1+1"
|
|
||||||
[ "$output" = "= 0.000000" ]
|
|
||||||
|
|
||||||
run bin "1+-1"
|
|
||||||
[ "$output" = "= 0.000000" ]
|
|
||||||
|
|
||||||
run bin "-1+-1"
|
|
||||||
[ "$output" = "= -2.000000" ]
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "simple subtraction" {
|
|
||||||
run bin "1-1"
|
|
||||||
[ "$output" = "= 0.000000" ]
|
|
||||||
|
|
||||||
run bin "-1-1"
|
|
||||||
[ "$output" = "= -2.000000" ]
|
|
||||||
|
|
||||||
run bin "1--1"
|
|
||||||
[ "$output" = "= 2.000000" ]
|
|
||||||
|
|
||||||
run bin "-1--1"
|
|
||||||
[ "$output" = "= 0.000000" ]
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "simple multiplication" {
|
|
||||||
run bin "1*2"
|
|
||||||
[ "$output" = "= 2.000000" ]
|
|
||||||
|
|
||||||
run bin "-1*2"
|
|
||||||
[ "$output" = "= -2.000000" ]
|
|
||||||
|
|
||||||
run bin "1*-1"
|
|
||||||
[ "$output" = "= -1.000000" ]
|
|
||||||
|
|
||||||
run bin "-1*-1"
|
|
||||||
[ "$output" = "= 1.000000" ]
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "simple division" {
|
|
||||||
run bin "1/2"
|
|
||||||
[ "$output" = "= 0.500000" ]
|
|
||||||
|
|
||||||
run bin "-1/2"
|
|
||||||
[ "$output" = "= -0.500000" ]
|
|
||||||
|
|
||||||
run bin "1/-1"
|
|
||||||
[ "$output" = "= -1.000000" ]
|
|
||||||
|
|
||||||
run bin "-1/-1"
|
|
||||||
[ "$output" = "= 1.000000" ]
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user