mirror of https://github.com/status-im/NimYAML.git
remove commented out old code
This commit is contained in:
parent
253a4623e4
commit
81e50d73d9
|
@ -205,17 +205,6 @@ suite "Serialization":
|
|||
assert result[3] == NegInf
|
||||
assert classify(result[4]) == fcNan
|
||||
|
||||
#test "Load nil string":
|
||||
# let input = "!<tag:nimyaml.org,2016:nil:string> \"\""
|
||||
# var result: string
|
||||
# load(input, result)
|
||||
# assert result.len == 0
|
||||
#
|
||||
#test "Dump nil string":
|
||||
# let input: string = ""
|
||||
# var output = dump(input, tsNone, asTidy, blockOnly)
|
||||
# assertStringEqual yamlDirs & "\n!n!nil:string \"\"", output
|
||||
|
||||
test "Load timestamps":
|
||||
let input = "[2001-12-15T02:59:43.1Z, 2001-12-14t21:59:43.10-05:00, 2001-12-14 21:59:43.10-5]"
|
||||
var result: seq[Time]
|
||||
|
@ -237,17 +226,6 @@ suite "Serialization":
|
|||
var output = dump(input, tsNone, asTidy, blockOnly)
|
||||
assertStringEqual yamlDirs & "\n- a\n- b", output
|
||||
|
||||
#test "Load nil seq":
|
||||
# let input = "!<tag:nimyaml.org,2016:nil:seq> \"\""
|
||||
# var result: seq[int]
|
||||
# load(input, result)
|
||||
# assert result.len == 0
|
||||
#
|
||||
#test "Dump nil seq":
|
||||
# let input: seq[int] = @[]
|
||||
# var output = dump(input, tsNone, asTidy, blockOnly)
|
||||
# assertStringEqual yamlDirs & "\n!n!nil:seq \"\"", output
|
||||
|
||||
test "Load char set":
|
||||
let input = "- a\n- b"
|
||||
var result: set[char]
|
||||
|
@ -641,31 +619,6 @@ next:
|
|||
assert result.c == "cde"
|
||||
assert result.d == "d"
|
||||
|
||||
#when not defined(JS):
|
||||
# test "Load nil values":
|
||||
# let input = "- ~\n- !!str ~"
|
||||
# var result: seq[ref string]
|
||||
# try: load(input, result)
|
||||
# except YamlConstructionError:
|
||||
# let ex = (ref YamlConstructionError)(getCurrentException())
|
||||
# echo "line ", ex.line, ", column ", ex.column, ": ", ex.msg
|
||||
# echo ex.lineContent
|
||||
# raise ex
|
||||
#
|
||||
# assert(result.len == 2)
|
||||
# assert(result[0] == nil)
|
||||
# assert(result[1][] == "~")
|
||||
#
|
||||
# test "Dump nil values":
|
||||
# var input = newSeq[ref string]()
|
||||
# input.add(nil)
|
||||
# input.add(new string)
|
||||
# input[1][] = "~"
|
||||
# var output = dump(input, tsRootOnly, asTidy, blockOnly)
|
||||
# assertStringEqual(yamlDirs &
|
||||
# "!n!system:seq(tag:yaml.org;2002:str) \n- !!null ~\n- !!str ~",
|
||||
# output)
|
||||
|
||||
test "Custom constructObject":
|
||||
let input = "- 1\n- !test:BetterInt 2"
|
||||
var result: seq[BetterInt]
|
||||
|
|
|
@ -1154,10 +1154,6 @@ proc constructChild*(s: var YamlStream, c: ConstructionContext,
|
|||
result: var string) =
|
||||
let item = s.peek()
|
||||
if item.kind == yamlScalar:
|
||||
#if item.scalarTag == yTagNimNilString:
|
||||
# discard s.next()
|
||||
# result = ""
|
||||
# return
|
||||
if item.scalarTag notin
|
||||
[yTagQuestionMark, yTagExclamationMark, yamlTag(string)]:
|
||||
raise s.constructionError("Wrong tag for string")
|
||||
|
@ -1238,8 +1234,6 @@ proc constructChild*[O](s: var YamlStream, c: ConstructionContext,
|
|||
raise e
|
||||
|
||||
proc representChild*(value: string, ts: TagStyle, c: SerializationContext) =
|
||||
#if value.len == 0: c.put(scalarEvent("", yTagNimNilString))
|
||||
#else:
|
||||
let tag = presentTag(string, ts)
|
||||
representObject(value, ts, c,
|
||||
if tag == yTagQuestionMark and guessType(value) != yTypeUnknown:
|
||||
|
@ -1248,8 +1242,6 @@ proc representChild*(value: string, ts: TagStyle, c: SerializationContext) =
|
|||
tag)
|
||||
|
||||
proc representChild*[T](value: seq[T], ts: TagStyle, c: SerializationContext) =
|
||||
#if value.len == 0: c.put(scalarEvent("", yTagNimNilSeq))
|
||||
#else:
|
||||
representObject(value, ts, c, presentTag(seq[T], ts))
|
||||
|
||||
proc representChild*[O](value: ref O, ts: TagStyle, c: SerializationContext) =
|
||||
|
|
|
@ -89,11 +89,6 @@ const
|
|||
## This tag is used in serialization for the name of a field of an
|
||||
## object. It may contain any string scalar that is a valid Nim symbol.
|
||||
|
||||
#yTagNimNilString* : TagId = 101.TagId ## for strings that are nil
|
||||
#yTagNimNilSeq* : TagId = 102.TagId ## \
|
||||
## for seqs that are nil. This tag is used regardless of the seq's generic
|
||||
## type parameter.
|
||||
|
||||
yFirstStaticTagId* : TagId = 1000.TagId ## \
|
||||
## The first ``TagId`` assigned by the ``setTagId`` templates.
|
||||
|
||||
|
@ -211,8 +206,6 @@ proc initSerializationTagLibrary*(): TagLibrary =
|
|||
result.tags[y"value"] = yTagValue
|
||||
result.tags[y"binary"] = yTagBinary
|
||||
result.tags[n"field"] = yTagNimField
|
||||
#result.tags[n"nil:string"] = yTagNimNilString
|
||||
#result.tags[n"nil:seq"] = yTagNimNilSeq
|
||||
|
||||
var
|
||||
serializationTagLibrary* = initSerializationTagLibrary() ## \
|
||||
|
@ -275,8 +268,6 @@ static:
|
|||
registeredUris.add(y"binary")
|
||||
# special tags used by serialization
|
||||
registeredUris.add(n"field")
|
||||
#registeredUris.add(n"nil:string")
|
||||
#registeredUris.add(n"nil:seq")
|
||||
|
||||
# tags for Nim's standard types
|
||||
setTagUri(char, n"system:char", yTagNimChar)
|
||||
|
|
Loading…
Reference in New Issue