head	1.1;
access;
symbols
	pkgsrc-2026Q1:1.1.0.48
	pkgsrc-2026Q1-base:1.1
	pkgsrc-2025Q4:1.1.0.46
	pkgsrc-2025Q4-base:1.1
	pkgsrc-2025Q3:1.1.0.44
	pkgsrc-2025Q3-base:1.1
	pkgsrc-2025Q2:1.1.0.42
	pkgsrc-2025Q2-base:1.1
	pkgsrc-2025Q1:1.1.0.40
	pkgsrc-2025Q1-base:1.1
	pkgsrc-2024Q4:1.1.0.38
	pkgsrc-2024Q4-base:1.1
	pkgsrc-2024Q3:1.1.0.36
	pkgsrc-2024Q3-base:1.1
	pkgsrc-2024Q2:1.1.0.34
	pkgsrc-2024Q2-base:1.1
	pkgsrc-2024Q1:1.1.0.32
	pkgsrc-2024Q1-base:1.1
	pkgsrc-2023Q4:1.1.0.30
	pkgsrc-2023Q4-base:1.1
	pkgsrc-2023Q3:1.1.0.28
	pkgsrc-2023Q3-base:1.1
	pkgsrc-2023Q2:1.1.0.26
	pkgsrc-2023Q2-base:1.1
	pkgsrc-2023Q1:1.1.0.24
	pkgsrc-2023Q1-base:1.1
	pkgsrc-2022Q4:1.1.0.22
	pkgsrc-2022Q4-base:1.1
	pkgsrc-2022Q3:1.1.0.20
	pkgsrc-2022Q3-base:1.1
	pkgsrc-2022Q2:1.1.0.18
	pkgsrc-2022Q2-base:1.1
	pkgsrc-2022Q1:1.1.0.16
	pkgsrc-2022Q1-base:1.1
	pkgsrc-2021Q4:1.1.0.14
	pkgsrc-2021Q4-base:1.1
	pkgsrc-2021Q3:1.1.0.12
	pkgsrc-2021Q3-base:1.1
	pkgsrc-2021Q2:1.1.0.10
	pkgsrc-2021Q2-base:1.1
	pkgsrc-2021Q1:1.1.0.8
	pkgsrc-2021Q1-base:1.1
	pkgsrc-2020Q4:1.1.0.6
	pkgsrc-2020Q4-base:1.1
	pkgsrc-2020Q3:1.1.0.4
	pkgsrc-2020Q3-base:1.1
	pkgsrc-2020Q2:1.1.0.2
	pkgsrc-2020Q2-base:1.1;
locks; strict;
comment	@# @;


1.1
date	2020.05.02.07.24.32;	author rillig;	state Exp;
branches;
next	;
commitid	tKxRCw5YybIWwD6C;


desc
@@


1.1
log
@regress: move tests for platform tools to tools-platform
@
text
@#! /bin/sh
# $NetBSD: awk-test.sh,v 1.8 2006/05/31 13:10:49 rillig Exp $
#

set -e

mydir=`dirname "$0"`
. "${mydir}/tests.subr"

#
# Functions specific for the awk testsuite.
#

# usage: test_assignment <testname> <input> <expected-output>
test_assignment() {
	testcase_start "$1"
	o=`echo "" | awk '{print var}' var="$2"`
	assert_equal "$1" "$3" "${o}"
}

# usage: test_passline <testname> <input>
test_passline() {
	testcase_start "$1"
	o=`awk '{print}' <<EOF
$2
EOF
`
	assert_equal "$1" "$2" "${o}"
}

#
# The actual test.
#

#
# Assignment of variables from the command line. The Solaris
# /usr/bin/awk does not conform to the POSIX specification, but passes
# the right hand side of the assignment uninterpreted. It fails the
# cmd.3 test case. The "for" loop makes sure that awk can handle strings
# of 4096 bytes length.
#
test_assignment "cmd.1" \
	"foo" "foo"
test_assignment "cmd.2" \
	"foo bar baz" "foo bar baz"
test_assignment "cmd.3" \
	"CPPFLAGS=\\\"-Dfoo=bar\\\"" "CPPFLAGS=\"-Dfoo=bar\""
line="a"
for i in 0 1 2 3 4 5 6 7 8 9 10 11 12; do
	test_assignment "cmd.2^${i}" "${line}" "${line}"
	line="${line}${line}"
done

#
# Passing strings from stdin to stdout. awk should be able to handle at
# least 2^12 characters per line.
#
# Solaris 9 /usr/bin/awk: 2559 bytes
# Solaris 9 /usr/bin/nawk: 6144 bytes
#
line="a"
for i in 0 1 2 3 4 5 6 7 8 9 10 11 12; do
	test_passline "line.2^${i}" "${line}"
	line="${line}${line}"
done
@
