Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@

##### Enhancements

* None.
* Improve test of "tag:yaml.org,2002:value".
[Norio Nomura](https://github.com/norio-nomura)
[#97](https://github.com/jpsim/Yams/issues/97)

##### Bug Fixes

Expand Down
2 changes: 1 addition & 1 deletion Sources/Yams/Constructor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ extension String: ScalarConstructible {
// This will happen while `Dictionary.flatten_mapping()` if `node.tag.name` was `.value`
if case let .mapping(mapping) = node {
for (key, value) in mapping where key.tag.name == .value {
return construct(from: value)!
return construct(from: value)
}
}

Expand Down
15 changes: 12 additions & 3 deletions Tests/YamsTests/ConstructorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,8 @@ class ConstructorTests: XCTestCase { // swiftlint:disable:this type_body_length
version: 2.3

"""
let objects = Array(try Yams.load_all(yaml: example))
let expected: [Any] = [
let nodes = Array(try Yams.compose_all(yaml: example))
let expected: [Node] = [
[
"link with": [ "library1.dll", "library2.dll" ]
], [
Expand All @@ -416,7 +416,16 @@ class ConstructorTests: XCTestCase { // swiftlint:disable:this type_body_length
]
]

YamsAssertEqual(objects, expected)
YamsAssertEqual(nodes, expected)

// value for "=" key will be returned on accessing `string`
XCTAssertEqual(nodes[1]["link with"]?[0]?.string, "library1.dll")
XCTAssertEqual(nodes[1]["link with"]?[1]?.string, "library2.dll")
// it also works as mapping
XCTAssertEqual(nodes[1]["link with"]?[0]?["="], "library1.dll")
XCTAssertEqual(nodes[1]["link with"]?[0]?["version"], "1.2")
XCTAssertEqual(nodes[1]["link with"]?[1]?["="], "library2.dll")
XCTAssertEqual(nodes[1]["link with"]?[1]?["version"], "2.3")
}

func testString() throws {
Expand Down