diff --git a/tests/bonsai/rpn.mk b/tests/bonsai/rpn.mk new file mode 100755 index 0000000..2ac1243 --- /dev/null +++ b/tests/bonsai/rpn.mk @@ -0,0 +1,43 @@ +# Copyright (c) 2024 Emma Tebibyte +# SPDX-License-Identifier: FSFAP +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice and this +# notice are preserved. This file is offered as-is, without any warranty. + +.PHONY: rpn_tests +rpn_tests: rpn_help rpn_add + +.PHONY: rpn_help +rpn_help: $(BIN)/rpn + ! $(BIN)/rpn -h + +.PHONY: rpn_add +rpn_add: $(BIN)/rpn + test "$$($(BIN)/rpn 1 2 +)" -eq 3 + test "$$($(BIN)/rpn 0.2 0.1 +)" = 0.3 + +.PHONY: rpn_sub +rpn_sub: $(BIN)/rpn + test "$$($(BIN)/rpn 23 5 -)" -eq 18 + test "$$($(BIN)/rpn 0.3 0.1)" = 0.2 + +.PHONY: rpn_mul +rpn_mul: $(BIN)/rpn + test "$$($(BIN)/rpn 1.2 3 '*')" = 3.6 + test "$$($(BIN)/rpn 0 3 '*')" -eq 0 + +.PHONY: rpn_div +rpn_div: $(BIN)/rpn + test "$$($(BIN)/rpn 12 5 /)" = 2.4 + test "$$($(BIN)/rpn 3 0 /)" -eq inf + +.PHONY: rpn_mod +rpn_mod: $(BIN)/rpn + test "$$($(BIN)/rpn 12 5 %)" -eq 2 + test "$$($(BIN)/rpn 9 4 %)" -eq 1 + +.PHONY: rpn_flr +rpn_flr: $(BIN)/rpn + test "$$($(BIN)/rpn 12 5 //)" -eq 2 + test "$$($(BIN)/rpn 9 4 //)" -eq 2