From 5d9a5933e6271800eeb063a87c81be63e70eb20c Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Sun, 12 Jan 2020 18:36:50 +0000 Subject: [PATCH] tests: Add test of the sort function. --- tests/10-function-sort.expected | 5 +++++ tests/10-function-sort.gl | 23 +++++++++++++++++++++++ tests/10-function-sort.sh | 24 ++++++++++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 tests/10-function-sort.expected create mode 100644 tests/10-function-sort.gl create mode 100755 tests/10-function-sort.sh diff --git a/tests/10-function-sort.expected b/tests/10-function-sort.expected new file mode 100644 index 0000000..7a5e336 --- /dev/null +++ b/tests/10-function-sort.expected @@ -0,0 +1,5 @@ + +p1 +p2 +x y +x y diff --git a/tests/10-function-sort.gl b/tests/10-function-sort.gl new file mode 100644 index 0000000..c4f582e --- /dev/null +++ b/tests/10-function-sort.gl @@ -0,0 +1,23 @@ +# Goals test. +# Copyright (C) 2020 Richard W.M. Jones +# Copyright (C) 2020 Red Hat Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +# Test the sort function which (like make) does a sort + uniq. + +let xs = sort ([ "p1", "p2", "p2", "p1", "x y", "x y", "x y", "" ]) + +goal all = { for x in %xs; do echo "$x"; done } diff --git a/tests/10-function-sort.sh b/tests/10-function-sort.sh new file mode 100755 index 0000000..9337555 --- /dev/null +++ b/tests/10-function-sort.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash +# Goals test. +# Copyright (C) 2020 Richard W.M. Jones +# Copyright (C) 2020 Red Hat Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +set -e + +goals -f 10-function-sort.gl > 10-function-sort.out +diff -u 10-function-sort.out 10-function-sort.expected +rm 10-function-sort.out -- 1.8.3.1