forked from bonsai/harakit
49 lines
1.3 KiB
Makefile
Executable File
49 lines
1.3 KiB
Makefile
Executable File
# Copyright (c) 2024 Emma Tebibyte <emma@tebibyte.media>
|
|
# 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 rpn_sub rpn_mul rpn_div rpn_mod rpn_flr rpn_stdin
|
|
|
|
.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 /)" = 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
|
|
|
|
# done last because all operations have been tested
|
|
.PHONY: rpn_stdin
|
|
rpn_stdin: $(BIN)/rpn
|
|
test "$$(printf '1\n2\n+\n3\n-\n' | $(BIN)/rpn | tail -n1)" -eq 0
|