From 90ca86ec9c3db804ac32ef942fa04a0aa8c133e7 Mon Sep 17 00:00:00 2001 From: Dave Henderson Date: Sat, 14 Oct 2017 13:51:01 -0400 Subject: Adding math functions Signed-off-by: Dave Henderson --- test/integration/math.bats | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 test/integration/math.bats (limited to 'test') diff --git a/test/integration/math.bats b/test/integration/math.bats new file mode 100644 index 00000000..0756485d --- /dev/null +++ b/test/integration/math.bats @@ -0,0 +1,39 @@ +#!/usr/bin/env bats + +load helper + +@test "'math.Add'" { + gomplate -i '{{ math.Add 1 2 3 4 }} {{ add -5 5 }}' + [ "$status" -eq 0 ] + [[ "${output}" == "10 0" ]] +} + +@test "'math.Sub'" { + gomplate -i '{{ math.Sub 10 5 }} {{ sub -5 5 }}' + [ "$status" -eq 0 ] + [[ "${output}" == "5 -10" ]] +} + +@test "'math.Mul'" { + gomplate -i '{{ math.Mul 1 2 3 4 }} {{ mul -5 5 }}' + [ "$status" -eq 0 ] + [[ "${output}" == "24 -25" ]] +} + +@test "'math.Div'" { + gomplate -i '{{ math.Div 5 3 }} {{ div -5 5 }}' + [ "$status" -eq 0 ] + [[ "${output}" == "1 -1" ]] +} + +@test "'math.Rem'" { + gomplate -i '{{ math.Rem 5 3 }} {{ rem 2 2 }}' + [ "$status" -eq 0 ] + [[ "${output}" == "2 0" ]] +} + +@test "'math.Pow'" { + gomplate -i '{{ math.Pow 8 4 }} {{ pow 2 2 }}' + [ "$status" -eq 0 ] + [[ "${output}" == "4096 4" ]] +} \ No newline at end of file -- cgit v1.2.3