Skip to content

Commit

Permalink
for simple read jons test
Browse files Browse the repository at this point in the history
  • Loading branch information
hyorigo committed Jun 24, 2024
1 parent 8f21934 commit a286cf0
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/file/file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,19 @@ func TestLoadModule_File(t *testing.T) {
assert.eq(l2, [text])
`),
},
{
name: `read json`,
script: itn.HereDoc(`
load('file', 'read_json')
j1 = read_json('testdata/json1.json')
assert.true(type(j1) == "dict")
assert.eq(j1["num"], 42)
assert.eq(j1["undef"], None)
assert.eq(j1["bool"], True)
assert.eq(j1["arr"], [1,2,3])
assert.eq(j1["obj"], {"foo": "bar", "baz": "qux"})
`),
},
{
name: `write no args`,
script: itn.HereDoc(`
Expand Down
1 change: 1 addition & 0 deletions lib/file/testdata/.gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*.txt binary
*.json binary
11 changes: 11 additions & 0 deletions lib/file/testdata/json1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"num": 42,
"str": "hello",
"bool": true,
"arr": [1, 2, 3],
"obj": {
"foo": "bar",
"baz": "qux"
},
"undef": null
}

0 comments on commit a286cf0

Please sign in to comment.