Cleanup examples
This commit is contained in:
parent
ea698bedcc
commit
a83ca8b31c
|
@ -568,7 +568,7 @@ proc fromPreserves*[T](v: var T; pr: Value): bool =
|
|||
type Foo {.preservesRecord: "foo".} = object
|
||||
x, y: int
|
||||
var foo: Foo
|
||||
assert(fromPreserve(foo, parsePreserves("""<foo 1 2>""")))
|
||||
assert(fromPreserves(foo, parsePreserves("""<foo 1 2>""")))
|
||||
assert(foo.x == 1)
|
||||
assert(foo.y == 2)
|
||||
when T is Value:
|
||||
|
@ -846,9 +846,9 @@ func step*(pr: Value; path: varargs[Value, toPreserves]): Option[Value] =
|
|||
## Works for sequences, records, and dictionaries.
|
||||
runnableExamples:
|
||||
import std/options
|
||||
assert step(parsePreserves("""<foo 1 2>"""), 1.toPreserve) == some(2.toPreserve)
|
||||
assert step(parsePreserves("""{ foo: 1 bar: 2}"""), "foo".toSymbol) == some(1.toPreserve)
|
||||
assert step(parsePreserves("""[ ]"""), 1.toPreserve) == none(Value)
|
||||
assert step(parsePreserves("""<foo 1 2>"""), 1.toPreserves) == some(2.toPreserves)
|
||||
assert step(parsePreserves("""{ foo: 1 bar: 2}"""), "foo".toSymbol) == some(1.toPreserves)
|
||||
assert step(parsePreserves("""[ ]"""), 1.toPreserves) == none(Value)
|
||||
result = some(pr)
|
||||
for index in path:
|
||||
if result.isSome:
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
# SPDX-License-Identifier: Unlicense
|
||||
|
||||
import std/[algorithm, hashes, options, sets, sequtils, tables]
|
||||
when not defined(nimNoLibc):
|
||||
import std/math
|
||||
import bigints
|
||||
|
||||
type
|
||||
|
|
Loading…
Reference in New Issue