Skip to content

Commit

Permalink
Add test(s) for bison (#34466)
Browse files Browse the repository at this point in the history
🤖 generated for as part of [expanding package test
coverage](#13623)

Signed-off-by: Josh Wolf <[email protected]>
  • Loading branch information
joshrwolf authored Nov 18, 2024
1 parent 14d6c7d commit 6b06a01
Showing 1 changed file with 87 additions and 4 deletions.
91 changes: 87 additions & 4 deletions bison.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,93 @@ update:
identifier: 193

test:
environment:
contents:
packages:
- build-base
- m4
- gcc
pipeline:
# AUTOGENERATED
- runs: |
- name: "Verify basic command availability"
runs: |
bison --version
yacc --version
bison --help
yacc --help
- name: "Test basic grammar parsing"
runs: |
cat > calc.y << 'EOF'
%{
#include <stdio.h>
void yyerror(const char *s) { fprintf(stderr, "%s\n", s); }
int yylex(void) { return 0; }
int main(void) { return 0; }
%}
%token NUMBER
%%
exp: NUMBER
%%
EOF
bison calc.y
- name: "Test yacc compatibility mode"
runs: |
cat > simple.y << 'EOF'
%token TOKEN
%%
start: TOKEN
%%
EOF
yacc simple.y
- name: "Verify different output formats"
runs: |
cat > test.y << 'EOF'
%token TEST
%%
rule: TEST
%%
EOF
bison -d test.y
test -f test.tab.h
test -f test.tab.c
- name: "Test verbose output generation"
runs: |
bison -v test.y
test -f test.output
- name: "Test XML output capability"
runs: |
bison -x test.y
test -f test.xml
- name: "Test error handling with invalid input"
runs: |
cat > invalid.y << 'EOF'
%invalid_directive
%%
invalid: grammar
%%
EOF
! bison invalid.y
- name: "Test grammar with multiple rules"
runs: |
cat > multi.y << 'EOF'
%token NUM ID
%%
expr: NUM
| ID
| expr '+' expr
| expr '*' expr
;
%%
EOF
bison multi.y
- name: "Test location tracking feature"
runs: |
cat > loc.y << 'EOF'
%locations
%token TOKEN
%%
start: TOKEN
%%
EOF
bison --locations loc.y
- name: "Verify report generation"
runs: |
bison --report=all test.y
test -f test.output

0 comments on commit 6b06a01

Please sign in to comment.