Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Jawk is a pure Java implementation of [AWK](https://en.wikipedia.org/wiki/AWK).
Jawk fully implements POSIX AWK, and adds support for the most commonly used gawk-specific features:

- Builtins, available by default through the built-in GNU Awk compatibility extension: `asort()`, `asorti()`, `typeof()`, `isarray()`, `mkbool()`, `gensub()`, `patsplit()`, `strtonum()`, `systime()`, `mktime()`, `strftime()`, `bindtextdomain()`, `dcgettext()`, `dcngettext()`, and `PROCINFO["sorted_in"]`-controlled array traversal
- Arrays of arrays (`a[i][j]`) and typed regexp literals (`@/re/`)
- Arrays of arrays (`a[i][j]`), including gawk-compatible runtime typing when arrays, scalars, and subarrays are passed to functions, and typed regexp literals (`@/re/`)
- Source inclusion with `@include`, namespaces with `@namespace` and `ns::name`, and indirect function calls such as `@functionName(args)`
- `BEGINFILE` / `ENDFILE` special patterns, with the `ERRNO` and `ARGIND` special variables, so a script can hook into the command-line file processing loop and skip unreadable files without a fatal error
- The `nextfile` statement
Expand Down
18 changes: 18 additions & 0 deletions src/it/java/io/jawk/gawk/AbstractGawkSuite.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@
*/

import static org.junit.Assume.assumeTrue;
import static org.junit.Assert.assertTrue;

import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import io.jawk.AwkTestSupport;
import io.jawk.CompatibilityTestResources;
import io.jawk.jrt.AwkRuntimeException;

/**
* Shared helpers for the explicit gawk compatibility integration suites
Expand All @@ -55,6 +58,21 @@ protected static String gawkText(String fileName) throws IOException {
return new String(Files.readAllBytes(gawkPath(fileName)), StandardCharsets.UTF_8);
}

protected static void assertGawkRuntimeFailure(String testName) throws Exception {
AwkTestSupport.TestResult result = AwkTestSupport
.awkTest("GAWK " + testName)
.script(gawkText(testName + ".awk"))
.expectThrow(AwkRuntimeException.class)
.run();
result.assertExpected();

String expectedTranscript = gawkText(testName + ".ok");
String expectedMessage = expectedTranscript.contains(" as an array") ?
"scalar as an array" : "array in a scalar context";
String actualMessage = result.thrownException().getMessage();
assertTrue(actualMessage, actualMessage.contains(expectedMessage));
}

protected static void skip(String reason) {
assumeTrue(reason, false);
}
Expand Down
4 changes: 2 additions & 2 deletions src/it/java/io/jawk/gawk/GawkExtensionIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void test_aadelete1() throws Exception {

@Test
public void test_aadelete2() throws Exception {
skip(NON_ZERO_TRANSCRIPT_REASON);
assertGawkRuntimeFailure("aadelete2");
}

@Test
Expand Down Expand Up @@ -848,7 +848,7 @@ public void test_mdim5() throws Exception {

@Test
public void test_mdim6() throws Exception {
skip(NON_ZERO_TRANSCRIPT_REASON);
assertGawkRuntimeFailure("mdim6");
}

@Test
Expand Down
32 changes: 16 additions & 16 deletions src/it/java/io/jawk/gawk/GawkIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void test_arrayind3() throws Exception {

@Test
public void test_arrayparm() throws Exception {
skip(NON_ZERO_TRANSCRIPT_REASON);
assertGawkRuntimeFailure("arrayparm");
}

@Test
Expand Down Expand Up @@ -153,17 +153,17 @@ public void test_arryref2() throws Exception {

@Test
public void test_arryref3() throws Exception {
skip(NON_ZERO_TRANSCRIPT_REASON);
assertGawkRuntimeFailure("arryref3");
}

@Test
public void test_arryref4() throws Exception {
skip(NON_ZERO_TRANSCRIPT_REASON);
assertGawkRuntimeFailure("arryref4");
}

@Test
public void test_arryref5() throws Exception {
skip(NON_ZERO_TRANSCRIPT_REASON);
assertGawkRuntimeFailure("arryref5");
}

@Test
Expand All @@ -178,37 +178,37 @@ public void test_arynasty() throws Exception {

@Test
public void test_aryprm1() throws Exception {
skip(NON_ZERO_TRANSCRIPT_REASON);
assertGawkRuntimeFailure("aryprm1");
}

@Test
public void test_aryprm2() throws Exception {
skip(NON_ZERO_TRANSCRIPT_REASON);
assertGawkRuntimeFailure("aryprm2");
}

@Test
public void test_aryprm3() throws Exception {
skip(NON_ZERO_TRANSCRIPT_REASON);
assertGawkRuntimeFailure("aryprm3");
}

@Test
public void test_aryprm4() throws Exception {
skip(NON_ZERO_TRANSCRIPT_REASON);
assertGawkRuntimeFailure("aryprm4");
}

@Test
public void test_aryprm5() throws Exception {
skip(NON_ZERO_TRANSCRIPT_REASON);
assertGawkRuntimeFailure("aryprm5");
}

@Test
public void test_aryprm6() throws Exception {
skip(NON_ZERO_TRANSCRIPT_REASON);
assertGawkRuntimeFailure("aryprm6");
}

@Test
public void test_aryprm7() throws Exception {
skip(NON_ZERO_TRANSCRIPT_REASON);
assertGawkRuntimeFailure("aryprm7");
}

@Test
Expand Down Expand Up @@ -651,7 +651,7 @@ public void test_fnarray2() throws Exception {

@Test
public void test_fnaryscl() throws Exception {
skip(NON_ZERO_TRANSCRIPT_REASON);
assertGawkRuntimeFailure("fnaryscl");
}

@Test
Expand Down Expand Up @@ -1530,7 +1530,7 @@ public void test_printfchar() throws Exception {

@Test
public void test_prmarscl() throws Exception {
skip(NON_ZERO_TRANSCRIPT_REASON);
assertGawkRuntimeFailure("prmarscl");
}

@Test
Expand Down Expand Up @@ -1845,17 +1845,17 @@ public void test_rswhite() throws Exception {

@Test
public void test_scalar() throws Exception {
skip(NON_ZERO_TRANSCRIPT_REASON);
assertGawkRuntimeFailure("scalar");
}

@Test
public void test_sclforin() throws Exception {
skip(NON_ZERO_TRANSCRIPT_REASON);
assertGawkRuntimeFailure("sclforin");
}

@Test
public void test_sclifin() throws Exception {
skip(NON_ZERO_TRANSCRIPT_REASON);
assertGawkRuntimeFailure("sclifin");
}

@Test
Expand Down
Loading
Loading