From 0cfaa202108f4c986263a9f9422698c797ebe898 Mon Sep 17 00:00:00 2001 From: Norio Nomura Date: Sat, 27 Jan 2018 14:03:36 +0900 Subject: [PATCH 1/4] Delete unnecessary forece unwrapping --- Sources/Yams/Constructor.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Yams/Constructor.swift b/Sources/Yams/Constructor.swift index db9d5e5e..f2ea4a90 100644 --- a/Sources/Yams/Constructor.swift +++ b/Sources/Yams/Constructor.swift @@ -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) } } From 4eceb55e81de1ad6408ecd192ee2a0a4b7b38aed Mon Sep 17 00:00:00 2001 From: Norio Nomura Date: Sat, 27 Jan 2018 14:05:35 +0900 Subject: [PATCH 2/4] Add more expectations to `ConstructorTests.testValue()` describing `.value` --- Tests/YamsTests/ConstructorTests.swift | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Tests/YamsTests/ConstructorTests.swift b/Tests/YamsTests/ConstructorTests.swift index a49e766c..1ae4b74a 100644 --- a/Tests/YamsTests/ConstructorTests.swift +++ b/Tests/YamsTests/ConstructorTests.swift @@ -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" ] ], [ @@ -416,7 +416,16 @@ class ConstructorTests: XCTestCase { // swiftlint:disable:this type_body_length ] ] - YamsAssertEqual(objects, expected) + YamsAssertEqual(nodes, expected) + + // "="'s value will be returned by accessing `string` + XCTAssertEqual(nodes[1]["link with"]?[0]?.string, "library1.dll") + XCTAssertEqual(nodes[1]["link with"]?[1]?.string, "library2.dll") + // it also work 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 { From ed20bbd40a88da136edc47052fa3ffef326e972d Mon Sep 17 00:00:00 2001 From: Norio Nomura Date: Sat, 27 Jan 2018 14:39:15 +0900 Subject: [PATCH 3/4] Fix comments --- Tests/YamsTests/ConstructorTests.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tests/YamsTests/ConstructorTests.swift b/Tests/YamsTests/ConstructorTests.swift index 1ae4b74a..e2a518b2 100644 --- a/Tests/YamsTests/ConstructorTests.swift +++ b/Tests/YamsTests/ConstructorTests.swift @@ -418,10 +418,10 @@ class ConstructorTests: XCTestCase { // swiftlint:disable:this type_body_length YamsAssertEqual(nodes, expected) - // "="'s value will be returned by accessing `string` + // 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 work as mapping + // 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") From cd0894673cb6031efe4dec702d74d229d2fc8794 Mon Sep 17 00:00:00 2001 From: Norio Nomura Date: Tue, 30 Jan 2018 08:48:10 +0900 Subject: [PATCH 4/4] Add a changelog entry --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e1bdbfa0..acf9f2e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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