From 5ff4e84b4acefcf75e5607ec9d620a6238b4b9f8 Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Tue, 17 Aug 2021 13:48:25 -0700 Subject: [PATCH] Support slash-separated lists --- CHANGELOG.md | 4 ++ lib/src/value.dart | 4 ++ pubspec.yaml | 2 +- test/function_test.dart | 104 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 113 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7dae363a..2eb79cd8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.0.0-beta.10 + +* Support slash-separated lists. + ## 1.0.0-beta.9 * No user-visible changes. diff --git a/lib/src/value.dart b/lib/src/value.dart index 9e806e34..a0f62f77 100644 --- a/lib/src/value.dart +++ b/lib/src/value.dart @@ -70,6 +70,8 @@ ListSeparator _protofySeparator(sass.ListSeparator separator) { return ListSeparator.COMMA; case sass.ListSeparator.space: return ListSeparator.SPACE; + case sass.ListSeparator.slash: + return ListSeparator.SLASH; case sass.ListSeparator.undecided: return ListSeparator.UNDECIDED; default: @@ -190,6 +192,8 @@ sass.ListSeparator _deprotofySeparator(ListSeparator separator) { return sass.ListSeparator.comma; case ListSeparator.SPACE: return sass.ListSeparator.space; + case ListSeparator.SLASH: + return sass.ListSeparator.slash; case ListSeparator.UNDECIDED: return sass.ListSeparator.undecided; default: diff --git a/pubspec.yaml b/pubspec.yaml index edf4ba2e..c2b3662e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: sass_embedded -version: 1.0.0-beta.9 +version: 1.0.0-dev description: An implementation of the Sass embedded protocol using Dart Sass. author: Sass Team homepage: https://github.com/sass/dart-sass-embedded diff --git a/test/function_test.dart b/test/function_test.dart index c5c4d64c..e0ccb6a5 100644 --- a/test/function_test.dart +++ b/test/function_test.dart @@ -497,6 +497,14 @@ void main() { expect(list.hasBrackets, isTrue); expect(list.separator, equals(ListSeparator.SPACE)); }); + + test("with a slash separator", () async { + var list = + (await _protofy(r"list.join([], [], $separator: slash)")).list; + expect(list.contents, isEmpty); + expect(list.hasBrackets, isTrue); + expect(list.separator, equals(ListSeparator.SLASH)); + }); }); group("without brackets", () { @@ -522,6 +530,14 @@ void main() { expect(list.hasBrackets, isFalse); expect(list.separator, equals(ListSeparator.SPACE)); }); + + test("with a slash separator", () async { + var list = + (await _protofy(r"list.join((), (), $separator: slash)")).list; + expect(list.contents, isEmpty); + expect(list.hasBrackets, isFalse); + expect(list.separator, equals(ListSeparator.SLASH)); + }); }); }); @@ -549,6 +565,15 @@ void main() { expect(list.hasBrackets, isTrue); expect(list.separator, equals(ListSeparator.SPACE)); }); + + test("with a slash separator", () async { + var list = + (await _protofy(r"list.join([true], [], $separator: slash)")) + .list; + expect(list.contents, equals([_true])); + expect(list.hasBrackets, isTrue); + expect(list.separator, equals(ListSeparator.SLASH)); + }); }); group("without brackets", () { @@ -567,6 +592,15 @@ void main() { expect(list.hasBrackets, isFalse); expect(list.separator, equals(ListSeparator.SPACE)); }); + + test("with a slash separator", () async { + var list = + (await _protofy(r"list.join(true, (), $separator: slash)")) + .list; + expect(list.contents, equals([_true])); + expect(list.hasBrackets, isFalse); + expect(list.separator, equals(ListSeparator.SLASH)); + }); }); }); @@ -601,6 +635,13 @@ void main() { expect(list.hasBrackets, isFalse); expect(list.separator, equals(ListSeparator.SPACE)); }); + + test("with a slash separator", () async { + var list = (await _protofy(r"list.slash(true, null, false)")).list; + expect(list.contents, equals([_true, _null, _false])); + expect(list.hasBrackets, isFalse); + expect(list.separator, equals(ListSeparator.SLASH)); + }); }); }); }); @@ -895,6 +936,15 @@ void main() { ..separator = ListSeparator.SPACE), "[]"); }); + + group("with a slash separator", () { + _testSerializationAndRoundTrip( + Value() + ..list = (Value_List() + ..hasBrackets = true + ..separator = ListSeparator.SLASH), + "[]"); + }); }); group("without brackets", () { @@ -927,6 +977,16 @@ void main() { "()", inspect: true); }); + + group("with a slash separator", () { + _testSerializationAndRoundTrip( + Value() + ..list = (Value_List() + ..hasBrackets = false + ..separator = ListSeparator.SLASH), + "()", + inspect: true); + }); }); }); @@ -963,6 +1023,16 @@ void main() { ..separator = ListSeparator.SPACE), "[true]"); }); + + group("with a slash separator", () { + _testSerializationAndRoundTrip( + Value() + ..list = (Value_List() + ..contents.add(_true) + ..hasBrackets = true + ..separator = ListSeparator.SLASH), + "[true]"); + }); }); group("without brackets", () { @@ -997,6 +1067,16 @@ void main() { ..separator = ListSeparator.SPACE), "true"); }); + + group("with a slash separator", () { + _testSerializationAndRoundTrip( + Value() + ..list = (Value_List() + ..contents.add(_true) + ..hasBrackets = false + ..separator = ListSeparator.SLASH), + "true"); + }); }); }); @@ -1025,6 +1105,18 @@ void main() { inspect: true), "[true null false]"); }); + + test("with a slash separator", () async { + expect( + await _deprotofy( + Value() + ..list = (Value_List() + ..contents.addAll([_true, _null, _false]) + ..hasBrackets = true + ..separator = ListSeparator.SLASH), + inspect: true), + "[true / null / false]"); + }); }); group("without brackets", () { @@ -1051,6 +1143,18 @@ void main() { inspect: true), "true null false"); }); + + test("with a slash separator", () async { + expect( + await _deprotofy( + Value() + ..list = (Value_List() + ..contents.addAll([_true, _null, _false]) + ..hasBrackets = false + ..separator = ListSeparator.SLASH), + inspect: true), + "true / null / false"); + }); }); }); });