Skip to content

Commit

Permalink
Fix import stew/results to pkg/results (#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
jangko authored Oct 15, 2024
1 parent 5127b26 commit 96fcb65
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
3 changes: 2 additions & 1 deletion json_serialization.nimble
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ skipDirs = @["tests", "fuzzer"]

requires "nim >= 1.6.0",
"serialization",
"stew"
"stew",
"results"

let nimc = getEnv("NIMC", "nim") # Which nim compiler to use
let lang = getEnv("NIMLANG", "c") # Which backend (c/cpp/js)
Expand Down
2 changes: 1 addition & 1 deletion json_serialization/stew/results.nim
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# those terms.

import
stew/results, ../../json_serialization/[reader, writer, lexer]
pkg/results, ../../json_serialization/[reader, writer, lexer]

export
results
Expand Down
21 changes: 10 additions & 11 deletions tests/test_writer.nim
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type
a: Opt[int]
b: Option[string]
c: int

createJsonFlavor YourJson,
omitOptionalFields = false

Expand Down Expand Up @@ -149,16 +149,16 @@ suite "Test writer":
)

let u = YourJson.encode(x)
check u.string == """{"a":123,"b":"nano","c":456}"""
check u == """{"a":123,"b":"nano","c":456}"""

let v = YourJson.encode(y)
check v.string == """{"a":null,"b":null,"c":999}"""
check v == """{"a":null,"b":null,"c":999}"""

let xx = MyJson.encode(x)
check xx.string == """{"a":123,"b":"nano","c":456}"""
check xx == """{"a":123,"b":"nano","c":456}"""

let yy = MyJson.encode(y)
check yy.string == """{"c":999}"""
check yy == """{"c":999}"""

test "writeField with object with optional fields":
let x = OWOF(
Expand All @@ -174,14 +174,14 @@ suite "Test writer":
)

let xx = MyJson.encode(x)
check xx.string == """{"a":123,"b":"nano","c":456}"""
check xx == """{"a":123,"b":"nano","c":456}"""
let yy = MyJson.encode(y)
check yy.string == """{"c":999}"""
check yy == """{"c":999}"""

let uu = YourJson.encode(x)
check uu.string == """{"a":123,"b":"nano","c":456}"""
check uu == """{"a":123,"b":"nano","c":456}"""
let vv = YourJson.encode(y)
check vv.string == """{"a":null,"b":null,"c":999}"""
check vv == """{"a":null,"b":null,"c":999}"""

test "Enum value representation primitives":
when DefaultFlavor.flavorEnumRep() == EnumAsString:
Expand Down Expand Up @@ -268,8 +268,7 @@ suite "Test writer":
# configuration: Json.configureJsonSerialization(Drawer, EnumAsNumber)
let u = Json.encode(Two)
check u == "1"

# configuration: MyJson.configureJsonSerialization(Drawer, EnumAsString)
let v = MyJson.encode(One)
check v == "\"One\""

0 comments on commit 96fcb65

Please sign in to comment.