Skip to content
This repository has been archived by the owner on Mar 29, 2023. It is now read-only.

Commit

Permalink
Add tests for different behaviour with asterisk
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiasNx committed Feb 1, 2022
1 parent a45d39c commit a8f314c
Show file tree
Hide file tree
Showing 6 changed files with 222 additions and 0 deletions.
26 changes: 26 additions & 0 deletions data/testing/asteriskArray/asteriskArray.fix
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# -------These work
set_array("TEST_TWO[]")
copy_field("test[].*", "TEST_TWO[].$append")
set_array("TEST_3[]")
copy_field("test[].*", "TEST_THREE[].$append")

replace_all("test[].*", "o", "__")
append("test[].*", " is cool")
replace_all("coll[].*.a", "o", "__")
prepend("coll[].*.a", "HELLO ")

lookup("animals[].*.Aanimal", "data/testing/asteriskArray/mapfile.tsv", "sep_char":"\t")

# ----------These do nothing
set_array("TEST_4[]")
copy_field("nestedTest[].*.test[].*", "TEST_4[].$append")
split_field("others[].*.tools","--")
sort_field("OTHERS[].*.dnimals[]")

# ----------These break:
# reverse("TEST_3[].*")
# reverse("ANIMALS[].*")

# sum("OTHERS[].*.dumbers[]")

# rename("OTHERS[].*", "d", "XY")
8 changes: 8 additions & 0 deletions data/testing/asteriskArray/asteriskArray.flux
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FLUX_DIR + "test.json"
|open-file
| as-records
| decode-json
| fix(FLUX_DIR + "asteriskArray.fix")
| encode-json(prettyPrinting="True")
| write(FLUX_DIR + "result.json")
;
44 changes: 44 additions & 0 deletions data/testing/asteriskArray/expected.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"test" : [ "One is cool", "Tw__ is cool", "Three is cool" ],
"coll" : [ {
"a" : "HELLO D__g"
}, {
"a" : "HELLO Ape"
}, {
"a" : "HELLO Giraffe"
}, {
"a" : "HELLO Cr__c__dile"
} ],
"others" : [ {
"name" : "Jake",
"animal" : "dog",
"tools" : [
{"1": "magic",
"2": "arms",
"3": "shapeShifting"}
]
}, {
"name" : "Finn",
"animal" : "human",
"tools" : [
{"1": "sword",
"2": "anotherSword",
"3": "arm"}
]
} ],
"OTHERS" : [ {
"name" : "Jake",
"dnimals" : [ "cat", "dog", "zebra" ],
"dumbers" : [ "20" ]
} ],
"animals" : [ {
"name" : "Jake",
"Aanimal" : "mammal"
}, {
"name" : "Blacky",
"Aanimal" : "bird"
} ],
"TEST_TWO" : [ "One", "Two", "Three" ],
"TEST_3" : [ "enO", "owT", "eerhT" ],
"Test_4": [ "One", "Two", "Three", "4", "5", "6"]
}
6 changes: 6 additions & 0 deletions data/testing/asteriskArray/mapfile.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dog mammal
cat mammal
parrot bird
shark fish
dragon ficational animal
unicorn ficational animal
53 changes: 53 additions & 0 deletions data/testing/asteriskArray/result.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"test" : [ "One is cool", "Tw__ is cool", "Three is cool" ],
"nestedTest" : [ {
"test" : [ "One", "Two", "Three" ]
}, {
"test" : [ "4", "5", "6" ]
} ],
"coll" : [ {
"a" : "HELLO D__g"
}, {
"a" : "HELLO Ape"
}, {
"a" : "HELLO Giraffe"
}, {
"a" : "HELLO Cr__c__dile"
} ],
"others" : [ {
"name" : "Jake",
"animal" : "dog",
"tools" : "magic--arms--shapeShifting"
}, {
"name" : "Finn",
"animal" : "human",
"tools" : "sword--anotherSword--arm"
} ],
"OTHERS" : [ {
"name" : "Jake",
"dnimals" : [ "dog", "zebra", "cat" ],
"dumbers" : [ "7", "2", "1", "10" ]
} ],
"animals" : [ {
"name" : "Jake",
"Aanimal" : "mammal"
}, {
"name" : "Blacky",
"Aanimal" : "bird"
} ],
"ANIMALS" : [ {
"Aanimal" : "dog",
"name" : "Jake"
}, {
"Aanimal" : "parrot",
"name" : "Blacky"
} ],
"TEST_TWO" : [ "One", "Two", "Three" ],
"TEST_3" : [ ],
"TEST_THREE" : [ {
"1" : "One",
"2" : "Two",
"3" : "Three"
} ],
"TEST_4" : [ ]
}
85 changes: 85 additions & 0 deletions data/testing/asteriskArray/test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
{
"test": [
"One",
"Two",
"Three"
],
"nestedTest": [
{
"test": [
"One",
"Two",
"Three"
]
},
{
"test": [
"4",
"5",
"6"
]
}
],
"coll": [
{
"a": "Dog"
},
{
"a": "Ape"
},
{
"a": "Giraffe"
},
{
"a": "Crocodile"
}
],
"others": [
{
"name": "Jake",
"animal": "dog",
"tools": "magic--arms--shapeShifting"
},
{
"name": "Finn",
"animal": "human",
"tools": "sword--anotherSword--arm"
}
],
"OTHERS": [
{
"name": "Jake",
"dnimals": [
"dog",
"zebra",
"cat"
],
"dumbers": [
"7",
"2",
"1",
"10"
]
}
],
"animals": [
{
"name": "Jake",
"Aanimal": "dog"
},
{
"name": "Blacky",
"Aanimal": "parrot"
}
],
"ANIMALS": [
{
"Aanimal": "dog",
"name": "Jake"
},
{
"Aanimal": "parrot",
"name": "Blacky"
}
]
}

0 comments on commit a8f314c

Please sign in to comment.