From 805d0efb4ff93f661ac1e35bb28277bf88300cb3 Mon Sep 17 00:00:00 2001 From: redxef Date: Wed, 18 Dec 2024 01:04:44 +0100 Subject: [PATCH] feat: add special case for string representation of cons which is a quote. --- Jellyfin.Plugin.SmartPlaylist/Lisp/Expression.cs | 7 +++++++ Tests/Tests.cs | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Jellyfin.Plugin.SmartPlaylist/Lisp/Expression.cs b/Jellyfin.Plugin.SmartPlaylist/Lisp/Expression.cs index 3cc1584..3daf3b6 100644 --- a/Jellyfin.Plugin.SmartPlaylist/Lisp/Expression.cs +++ b/Jellyfin.Plugin.SmartPlaylist/Lisp/Expression.cs @@ -243,6 +243,13 @@ namespace Jellyfin.Plugin.SmartPlaylist.Lisp { return $"{Item1} . {Item2}"; } public override string? ToString() { + if (Item1 is Symbol SymbolItem1 + && SymbolItem1.Name() == "quote" + && Item2 is Cons ConsItem2 + && ConsItem2.Item2.Equals(Boolean.FALSE) + ) { + return $"'{ConsItem2.Item1}"; + } return $"({ToStringSimple()})"; } } diff --git a/Tests/Tests.cs b/Tests/Tests.cs index da690c0..cd85678 100644 --- a/Tests/Tests.cs +++ b/Tests/Tests.cs @@ -70,7 +70,7 @@ namespace Tests program = "(abc '(1 2 3))"; sts = StringTokenStream.generate(program); p = new Parser(sts); - Assert.Equal("(abc (quote (1 2 3)))", string.Format("{0}", p.parse())); + Assert.Equal(program, string.Format("{0}", p.parse())); program = "(abc \"'(1 2 3)\")"; sts = StringTokenStream.generate(program);