SHELL=/bin/bash

go:
	#./set-arithmetic --help
	#./set-arithmetic
	./this-pylint --which-2 None --which-3 /usr/local/cpython-3.9/bin/pylint --to-pylint set-arithmetic
	./set-arithmetic --union abc def | sort > union.output
	diff union.output union.expected
	./set-arithmetic --intersection abcd defg | sort > intersection.output
	diff intersection.output intersection.expected
	./set-arithmetic --difference abcd abc | sort > difference.output
	diff difference.output difference.expected
	./set-arithmetic --symmetric-difference abcd defg | sort > symmetric-difference.output
	diff symmetric-difference.output symmetric-difference.expected
	./set-arithmetic --is-subset abc abcd; echo $$? > is-subset1.output
	diff is-subset1.output is-subset1.expected
	./set-arithmetic --is-subset abcd abc; echo $$? > is-subset2.output
	diff is-subset2.output is-subset2.expected
	./set-arithmetic --is-proper-subset abc abcd; echo $$? > is-proper-subset1.output
	diff is-proper-subset1.output is-proper-subset1.expected
	./set-arithmetic --is-proper-subset abc abc; echo $$? > is-proper-subset2.output
	diff is-proper-subset2.output is-proper-subset2.expected
	./set-arithmetic --is-equal abc abc; echo $$? > is-equal1.output
	diff is-equal1.output is-equal1.expected
	./set-arithmetic --is-equal abc abcd; echo $$? > is-equal2.output
	diff is-equal2.output is-equal2.expected
	./set-arithmetic --is-equal /etc/services <(tac /etc/services)
	./set-arithmetic --is-not-equal /etc/services /etc/passwd
	#
	seq 1 10 > fuzzy-match-1.fodder
	seq 11 20 > fuzzy-match-2.fodder
	./set-arithmetic --fuzzy-match fuzzy-match-1.fodder fuzzy-match-2.fodder
	[ "$$(./set-arithmetic --fuzzy-match fuzzy-match-1.fodder fuzzy-match-2.fodder)" = 0 ]
	#
	seq 1 10 > fuzzy-match-1.fodder
	seq 1 10 > fuzzy-match-2.fodder
	./set-arithmetic --fuzzy-match fuzzy-match-1.fodder fuzzy-match-2.fodder
	[ "$$(./set-arithmetic --fuzzy-match fuzzy-match-1.fodder fuzzy-match-2.fodder)" = 1 ]
	#
	seq 0 9 > fuzzy-match-1.fodder
	seq 5 14 > fuzzy-match-2.fodder
	./set-arithmetic --fuzzy-match fuzzy-match-1.fodder fuzzy-match-2.fodder
	./set-arithmetic --fuzzy-match fuzzy-match-1.fodder fuzzy-match-2.fodder | grep -q '^0.333*$$'
	#
	seq 1 12 > fuzzy-match-1.fodder
	seq 10 20 > fuzzy-match-2.fodder
	./set-arithmetic --fuzzy-match fuzzy-match-1.fodder fuzzy-match-2.fodder
	[ "$$(./set-arithmetic --fuzzy-match fuzzy-match-1.fodder fuzzy-match-2.fodder)" = 0.15 ]
	@echo All tests passed

install:
	./install-file --file set-arithmetic --directory /usr/local/bin/.

clean:
	rm -f *.output
	rm -f *.fodder