fix: allow programs to not be a list.

This commit is contained in:
redxef 2024-12-18 01:15:54 +01:00
parent 805d0efb4f
commit c9d7f1ee60
Signed by: redxef
GPG key ID: 7DAC3AA211CBD921
2 changed files with 6 additions and 2 deletions

View file

@ -78,8 +78,11 @@ namespace Jellyfin.Plugin.SmartPlaylist.Lisp.Compiler {
} }
value += t; value += t;
} }
if (value.Equals("")) {
return null; return null;
} }
return new AtomToken(value);
}
} }
class CharStream: Stream<char> { class CharStream: Stream<char> {
@ -101,7 +104,7 @@ namespace Jellyfin.Plugin.SmartPlaylist.Lisp.Compiler {
if (prev_avail == program.Available() && prev_avail == 0) { if (prev_avail == program.Available() && prev_avail == 0) {
break; break;
} else if (prev_avail == program.Available()) { } else if (prev_avail == program.Available()) {
throw new ApplicationException("Program is invalid"); throw new ApplicationException($"Program is invalid, still available: {program.Available()}");
} }
prev_avail = program.Available(); prev_avail = program.Available();
foreach (Type c in _classes) { foreach (Type c in _classes) {

View file

@ -148,6 +148,7 @@ namespace Tests
(if (> 0 1) (car (quote (1 2 3))) (cdr (quote (2 3 4))))) (if (> 0 1) (car (quote (1 2 3))) (cdr (quote (2 3 4)))))
""").ToString()); """).ToString());
Assert.Equal("a", e.eval("'a").ToString());
} }
[Fact] [Fact]