Skip to content

Commit

Permalink
unit-test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
johnkerl committed Dec 18, 2023
1 parent b0bc28f commit e4be503
Show file tree
Hide file tree
Showing 10 changed files with 134 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/cases/dsl-match/0001/cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mlr --ojsonl --from ${CASEDIR}/input put -f ${CASEDIR}/mlr
Empty file.
11 changes: 11 additions & 0 deletions test/cases/dsl-match/0001/expout
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{"x": "a", "y": "b", "z": false}
{"x": "abc", "y": "ab", "z": true}
{"x": " 345 78 ", "y": "([0-9]+)", "z": true}
{"x": " 345 78 ", "y": "([0-9]+) ([0-9]+)", "z": true}
{"x": " 345 78 ", "y": "([0-9]+)(.)([0-9]+)", "z": true}
{"x": "", "y": "", "z": true}
{"x": "", "y": "b", "z": false}
{"x": "a", "y": "", "z": true}
{"x": "a", "z": (error)}
{"y": "b", "z": (error)}
{"foo": "bar", "z": (error)}
11 changes: 11 additions & 0 deletions test/cases/dsl-match/0001/input
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
x=a,y=b
x=abc,y=ab
x= 345 78 ,y=([0-9]+)
x= 345 78 ,y=([0-9]+) ([0-9]+)
x= 345 78 ,y=([0-9]+)(.)([0-9]+)
x=,y=
x=,y=b
x=a,y=
x=a
y=b
foo=bar
1 change: 1 addition & 0 deletions test/cases/dsl-match/0001/mlr
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$z = match($x, $y)
1 change: 1 addition & 0 deletions test/cases/dsl-match/0002/cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mlr --ojson --from ${CASEDIR}/input put -f ${CASEDIR}/mlr
Empty file.
97 changes: 97 additions & 0 deletions test/cases/dsl-match/0002/expout
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
[
{
"x": "a",
"y": "b",
"z": {
"matched": false
}
},
{
"x": "abc",
"y": "ab",
"z": {
"matched": true,
"full_capture": "ab",
"full_start": 1,
"full_end": 2
}
},
{
"x": " 345 78 ",
"y": "([0-9]+)",
"z": {
"matched": true,
"full_capture": "345",
"full_start": 3,
"full_end": 5,
"captures": ["345"],
"starts": [3],
"ends": [5]
}
},
{
"x": " 345 78 ",
"y": "([0-9]+) ([0-9]+)",
"z": {
"matched": true,
"full_capture": "345 78",
"full_start": 3,
"full_end": 8,
"captures": ["345", "78"],
"starts": [3, 7],
"ends": [5, 8]
}
},
{
"x": " 345 78 ",
"y": "([0-9]+)(.)([0-9]+)",
"z": {
"matched": true,
"full_capture": "345 78",
"full_start": 3,
"full_end": 8,
"captures": ["345", " ", "78"],
"starts": [3, 6, 7],
"ends": [5, 6, 8]
}
},
{
"x": "",
"y": "",
"z": {
"matched": true,
"full_capture": "",
"full_start": 1,
"full_end": 0
}
},
{
"x": "",
"y": "b",
"z": {
"matched": false
}
},
{
"x": "a",
"y": "",
"z": {
"matched": true,
"full_capture": "",
"full_start": 1,
"full_end": 0
}
},
{
"x": "a",
"z": (error)
},
{
"y": "b",
"z": (error)
},
{
"foo": "bar",
"z": (error)
}
]
11 changes: 11 additions & 0 deletions test/cases/dsl-match/0002/input
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
x=a,y=b
x=abc,y=ab
x= 345 78 ,y=([0-9]+)
x= 345 78 ,y=([0-9]+) ([0-9]+)
x= 345 78 ,y=([0-9]+)(.)([0-9]+)
x=,y=
x=,y=b
x=a,y=
x=a
y=b
foo=bar
1 change: 1 addition & 0 deletions test/cases/dsl-match/0002/mlr
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$z = matchx($x, $y)

0 comments on commit e4be503

Please sign in to comment.