From af904772e788cbe1dfe66b5abaada5bae6afa24f Mon Sep 17 00:00:00 2001 From: Javier Mora Date: Sat, 14 Dec 2024 19:53:59 +0100 Subject: [PATCH] Units: Add unit tests for null tags Add unit tests in various languages (JSON, Tcl, Verilog/SystemVerilog) to test if null tags are properly implemented. Note that Tcl doesn't support empty namespace names using `::` syntax since `foo::::bar` is synonymous of `foo::bar`, so we're not testing empty namespace names there, only empty proc names. Note that the current Tcl parser doesn't seem to support {braced} identifiers at all (including the empty identifier), so perhaps adding support for null tags in Tcl is trickier. --- Units/null-tags.r/json-null-tag.d/args.ctags | 1 + .../null-tags.r/json-null-tag.d/expected.tags | 31 +++++++++++ Units/null-tags.r/json-null-tag.d/input.json | 50 ++++++++++++++++++ Units/null-tags.r/tcl-null-tag.d/args.ctags | 1 + .../null-tags.r/tcl-null-tag.d/expected.tags | 11 ++++ Units/null-tags.r/tcl-null-tag.d/input.tcl | 14 +++++ .../null-tags.r/verilog-null-tag.d/args.ctags | 1 + .../verilog-null-tag.d/expected.tags | 14 +++++ Units/null-tags.r/verilog-null-tag.d/input.sv | 51 +++++++++++++++++++ 9 files changed, 174 insertions(+) create mode 100644 Units/null-tags.r/json-null-tag.d/args.ctags create mode 100644 Units/null-tags.r/json-null-tag.d/expected.tags create mode 100644 Units/null-tags.r/json-null-tag.d/input.json create mode 100644 Units/null-tags.r/tcl-null-tag.d/args.ctags create mode 100644 Units/null-tags.r/tcl-null-tag.d/expected.tags create mode 100644 Units/null-tags.r/tcl-null-tag.d/input.tcl create mode 100644 Units/null-tags.r/verilog-null-tag.d/args.ctags create mode 100644 Units/null-tags.r/verilog-null-tag.d/expected.tags create mode 100644 Units/null-tags.r/verilog-null-tag.d/input.sv diff --git a/Units/null-tags.r/json-null-tag.d/args.ctags b/Units/null-tags.r/json-null-tag.d/args.ctags new file mode 100644 index 0000000000..5ee5f79f70 --- /dev/null +++ b/Units/null-tags.r/json-null-tag.d/args.ctags @@ -0,0 +1 @@ +--sort=no diff --git a/Units/null-tags.r/json-null-tag.d/expected.tags b/Units/null-tags.r/json-null-tag.d/expected.tags new file mode 100644 index 0000000000..ba1baed899 --- /dev/null +++ b/Units/null-tags.r/json-null-tag.d/expected.tags @@ -0,0 +1,31 @@ + input.json /^ "": "Empty",$/;" s object:legend + input.json /^ "": "Nonempty"$/;" s object:legend +legend input.json /^ "legend": {$/;" o + input.json /^ "": "Empty",$/;" s object:.. +eeen input.json /^ "eeen": "Nonempty"$/;" s object:.. + input.json /^ "": {$/;" o object:. + input.json /^ "": "Empty",$/;" s object:..een +eenn input.json /^ "eenn": "Nonempty"$/;" s object:..een +een input.json /^ "een": {$/;" o object:. + input.json /^ "": "Empty",$/;" s object:.en. +enen input.json /^ "enen": "Nonempty"$/;" s object:.en. + input.json /^ "": {$/;" o object:.en + input.json /^ "": "Empty",$/;" s object:.en.enn +ennn input.json /^ "ennn": "Nonempty"$/;" s object:.en.enn +enn input.json /^ "enn": {$/;" o object:.en +en input.json /^ "en": {$/;" o object: + input.json /^ "": {$/;" o + input.json /^ "": "Empty",$/;" s object:n.. +neen input.json /^ "neen": "Nonempty"$/;" s object:n.. + input.json /^ "": {$/;" o object:n. + input.json /^ "": "Empty",$/;" s object:n..nen +nenn input.json /^ "nenn": "Nonempty"$/;" s object:n..nen +nen input.json /^ "nen": {$/;" o object:n. + input.json /^ "": "Empty",$/;" s object:n.nn. +nnen input.json /^ "nnen": "Nonempty"$/;" s object:n.nn. + input.json /^ "": {$/;" o object:n.nn + input.json /^ "": "Empty",$/;" s object:n.nn.nnn +nnnn input.json /^ "nnnn": "Nonempty"$/;" s object:n.nn.nnn +nnn input.json /^ "nnn": {$/;" o object:n.nn +nn input.json /^ "nn": {$/;" o object:n +n input.json /^ "n": {$/;" o diff --git a/Units/null-tags.r/json-null-tag.d/input.json b/Units/null-tags.r/json-null-tag.d/input.json new file mode 100644 index 0000000000..3fe098a30b --- /dev/null +++ b/Units/null-tags.r/json-null-tag.d/input.json @@ -0,0 +1,50 @@ +{ + "legend": { + "": "Empty", + "": "Nonempty" + }, + "": { + "": { + "": { + "": "Empty", + "eeen": "Nonempty" + }, + "een": { + "": "Empty", + "eenn": "Nonempty" + } + }, + "en": { + "": { + "": "Empty", + "enen": "Nonempty" + }, + "enn": { + "": "Empty", + "ennn": "Nonempty" + } + } + }, + "n": { + "": { + "": { + "": "Empty", + "neen": "Nonempty" + }, + "nen": { + "": "Empty", + "nenn": "Nonempty" + } + }, + "nn": { + "": { + "": "Empty", + "nnen": "Nonempty" + }, + "nnn": { + "": "Empty", + "nnnn": "Nonempty" + } + } + } +} diff --git a/Units/null-tags.r/tcl-null-tag.d/args.ctags b/Units/null-tags.r/tcl-null-tag.d/args.ctags new file mode 100644 index 0000000000..5ee5f79f70 --- /dev/null +++ b/Units/null-tags.r/tcl-null-tag.d/args.ctags @@ -0,0 +1 @@ +--sort=no diff --git a/Units/null-tags.r/tcl-null-tag.d/expected.tags b/Units/null-tags.r/tcl-null-tag.d/expected.tags new file mode 100644 index 0000000000..a4c5e8548e --- /dev/null +++ b/Units/null-tags.r/tcl-null-tag.d/expected.tags @@ -0,0 +1,11 @@ + input.tcl /^proc aaa {} {return Empty }$/;" p +aaa input.tcl /^proc aaa {} {return Normal}$/;" p +a input.tcl /^proc {a} {} {return Braced}$/;" p +ns1 input.tcl /^namespace eval ns1 {$/;" n + input.tcl /^ proc {} {} {return Empty }$/;" p namespace:::ns1 +bbb input.tcl /^ proc bbb {} {return Normal}$/;" p namespace:::ns1 +b input.tcl /^ proc {b} {} {return Braced}$/;" p namespace:::ns1 +ns2 input.tcl /^namespace eval ns2$/;" n + input.tcl /^proc ns2:: {} {return Empty }$/;" p namespace:ns2 +ccc input.tcl /^proc ns2::ccc {} {return Normal}$/;" p namespace:ns2 +c input.tcl /^proc {ns2::c} {} {return Braced}$/;" p namespace:ns2 diff --git a/Units/null-tags.r/tcl-null-tag.d/input.tcl b/Units/null-tags.r/tcl-null-tag.d/input.tcl new file mode 100644 index 0000000000..cd64a17c76 --- /dev/null +++ b/Units/null-tags.r/tcl-null-tag.d/input.tcl @@ -0,0 +1,14 @@ +proc {} {} {return Empty } +proc aaa {} {return Normal} +proc {a} {} {return Braced} + +namespace eval ns1 { + proc {} {} {return Empty } + proc bbb {} {return Normal} + proc {b} {} {return Braced} +} + +namespace eval ns2 +proc ns2:: {} {return Empty } +proc ns2::ccc {} {return Normal} +proc {ns2::c} {} {return Braced} diff --git a/Units/null-tags.r/verilog-null-tag.d/args.ctags b/Units/null-tags.r/verilog-null-tag.d/args.ctags new file mode 100644 index 0000000000..5ee5f79f70 --- /dev/null +++ b/Units/null-tags.r/verilog-null-tag.d/args.ctags @@ -0,0 +1 @@ +--sort=no diff --git a/Units/null-tags.r/verilog-null-tag.d/expected.tags b/Units/null-tags.r/verilog-null-tag.d/expected.tags new file mode 100644 index 0000000000..517cae4de2 --- /dev/null +++ b/Units/null-tags.r/verilog-null-tag.d/expected.tags @@ -0,0 +1,14 @@ + input.sv /^module \\ ;$/;" m + input.sv /^ } \\ ;$/;" S module: + input.sv /^ } \\ ;$/;" w struct:. +een input.sv /^ } \\een ;$/;" w struct:. +en input.sv /^ } \\en ;$/;" S module: + input.sv /^ } \\ ;$/;" w struct:.en +enn input.sv /^ } \\enn ;$/;" w struct:.en +n input.sv /^module \\n ;$/;" m + input.sv /^ } \\ ;$/;" S module:n + input.sv /^ } \\ ;$/;" w struct:n. +nen input.sv /^ } \\nen ;$/;" w struct:n. +nn input.sv /^ } \\nn ;$/;" S module:n + input.sv /^ } \\ ;$/;" w struct:n.nn +nnn input.sv /^ } \\nnn ;$/;" w struct:n.nn diff --git a/Units/null-tags.r/verilog-null-tag.d/input.sv b/Units/null-tags.r/verilog-null-tag.d/input.sv new file mode 100644 index 0000000000..e563b98c84 --- /dev/null +++ b/Units/null-tags.r/verilog-null-tag.d/input.sv @@ -0,0 +1,51 @@ +/* Legend: + * = empty (null) + * = non-empty + */ + +module \ ; + struct { + struct { + logic \ ; + logic \eeen ; + } \ ; + struct { + logic \ ; + logic \eenn ; + } \een ; + } \ ; + struct { + struct { + logic \ ; + logic \enen ; + } \ ; + struct { + logic \ ; + logic \ennn ; + } \enn ; + } \en ; +endmodule + +module \n ; + struct { + struct { + logic \ ; + logic \neen ; + } \ ; + struct { + logic \ ; + logic \nenn ; + } \nen ; + } \ ; + struct { + struct { + logic \ ; + logic \nnen ; + } \ ; + struct { + logic \ ; + logic \nnnn ; + } \nnn ; + } \nn ; +endmodule +