Skip to content

Commit

Permalink
fixes #141. Version 2.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
flyx committed Jan 18, 2024
1 parent eee4568 commit 48a90e3
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 11 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 2.1.1

Bugfixes:

* Fixed a bug that prevented float values to be serialized (#141)

## 2.1.0

Features:
Expand Down
2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
};
outputs = { self, nixpkgs, utils, nix-filter }:
let
version = "2.1.0";
version = "2.1.1";
systemDependent = with utils.lib;
eachSystem allSystems (system:
let pkgs = nixpkgs.legacyPackages.${system};
Expand Down
10 changes: 5 additions & 5 deletions test/tnative.nim
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type
name: string
case kind: AnimalKind
of akCat:
purringIntensity: int
purringIntensity: float
of akDog: barkometer: int

DumbEnum = enum
Expand Down Expand Up @@ -488,26 +488,26 @@ suite "Serialization":

dualTest "Load custom variant object":
let input =
"---\n- - name: Bastet\n - kind: akCat\n - purringIntensity: 7\n" &
"---\n- - name: Bastet\n - kind: akCat\n - purringIntensity: 7.2\n" &
"- - name: Anubis\n - kind: akDog\n - barkometer: 13"
var result: seq[Animal]
load(input, result)
assert result.len == 2
assert result[0].name == "Bastet"
assert result[0].kind == akCat
assert result[0].purringIntensity == 7
assert abs(result[0].purringIntensity - 7.2) < 1E-7
assert result[1].name == "Anubis"
assert result[1].kind == akDog
assert result[1].barkometer == 13

test "Dump custom variant object":
let input = @[Animal(name: "Bastet", kind: akCat, purringIntensity: 7),
let input = @[Animal(name: "Bastet", kind: akCat, purringIntensity: 7.2),
Animal(name: "Anubis", kind: akDog, barkometer: 13)]
var output = blockOnlyDumper().dump(input)
assertStringEqual "" &
"- - name: Bastet\n" &
" - kind: akCat\n" &
" - purringIntensity: 7\n" &
" - purringIntensity: 7.2\n" &
"- - name: Anubis\n" &
" - kind: akDog\n" &
" - barkometer: 13\n", output
Expand Down
2 changes: 1 addition & 1 deletion yaml.nimble
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Package

version = "2.1.0"
version = "2.1.1"
author = "Felix Krause"
description = "YAML 1.2 implementation for Nim"
license = "MIT"
Expand Down
8 changes: 4 additions & 4 deletions yaml/native.nim
Original file line number Diff line number Diff line change
Expand Up @@ -451,10 +451,10 @@ proc representObject*[T: float|float32|float64](
) {.raises: [].} =
## represents a float value as YAML scalar
case value
of Inf: ctx.put(scalarEvent(".inf", tag, ctx.scalarStyleFor(T)))
of NegInf: ctx.put(scalarEvent("-.inf", tag, ctx.scalarStyleFor(T)))
of NaN: ctx.put(scalarEvent(".nan", tag, ctx.scalarStyleFor(T)))
else: ctx.put(scalarEvent($value, tag, ctx.scalarStyleFor(T)))
of Inf: ctx.put(scalarEvent(".inf", tag, yAnchorNone, ctx.scalarStyleFor(T)))
of NegInf: ctx.put(scalarEvent("-.inf", tag, yAnchorNone, ctx.scalarStyleFor(T)))
of NaN: ctx.put(scalarEvent(".nan", tag, yAnchorNone, ctx.scalarStyleFor(T)))
else: ctx.put(scalarEvent($value, tag, yAnchorNone, ctx.scalarStyleFor(T)))

proc yamlTag*(T: typedesc[bool]): Tag {.inline, raises: [].} = yTagBoolean

Expand Down

0 comments on commit 48a90e3

Please sign in to comment.