Compare commits

..

No commits in common. "889df318db4cd8a0c482da7988a621a2ecac7184" and "0a5aed38ebcfae418d573b5e9f0fc127e230fc44" have entirely different histories.

2 changed files with 2 additions and 19 deletions

View file

@ -182,21 +182,13 @@ namespace Jellyfin.Plugin.SmartPlaylist.Lisp {
private static Expression _invoke(IEnumerable<Expression> args) { private static Expression _invoke(IEnumerable<Expression> args) {
Object o = (Object) args.First(); Object o = (Object) args.First();
String s = (String) args.Skip(1).First(); String s = (String) args.Skip(1).First();
IEnumerable<Expression> l; Cons l = (Cons) args.Skip(2).First();
if (args.Skip(2).First() is Boolean lb && lb == Boolean.FALSE) {
l = new List<Expression>();
} else if (args.Skip(2).First() is Cons lc) {
l = lc.ToList();
} else {
throw new ApplicationException($"Expected a list of arguments, got {args.Skip(2).First()}");
}
IList<Expression> r = new List<Expression>(); IList<Expression> r = new List<Expression>();
MethodInfo? mi = o.Value().GetType().GetMethod(s.Value()); MethodInfo? mi = o.Value().GetType().GetMethod(s.Value());
if (mi == null) { if (mi == null) {
throw new ApplicationException($"{o.Value()} has not method {s.Value()}"); throw new ApplicationException($"{o.Value()} has not method {s.Value()}");
} }
object?[]? l_ = l.Select<Expression, object?>(x => { object?[]? l_ = l.ToList().Select<Expression, object?>(x => {
switch (x) { switch (x) {
case Integer s: case Integer s:
return s.Value(); return s.Value();

View file

@ -16,9 +16,6 @@ namespace Tests
} }
public int i { get => _i; } public int i { get => _i; }
public bool b { get => _b; } public bool b { get => _b; }
public int I() {
return _i;
}
} }
public class Test { public class Test {
@ -203,8 +200,6 @@ namespace Tests
Assert.Equal(((Lisp_Boolean)r).Value(), true); Assert.Equal(((Lisp_Boolean)r).Value(), true);
r = e.eval("""(getitems o "i" "b")"""); r = e.eval("""(getitems o "i" "b")""");
Assert.Equal(string.Format("{0}", r), "(5 nil)"); Assert.Equal(string.Format("{0}", r), "(5 nil)");
r = e.eval("""(invoke o "I" nil)""");
Assert.Equal(string.Format("{0}", r), "5");
} }
[Fact] [Fact]
@ -220,10 +215,6 @@ namespace Tests
Assert.Equal("t", e.eval("(and (quote (1 2 3 4)))").ToString()); Assert.Equal("t", e.eval("(and (quote (1 2 3 4)))").ToString());
Assert.Equal("t", e.eval("(or (quote (nil nil 1 nil)))").ToString()); Assert.Equal("t", e.eval("(or (quote (nil nil 1 nil)))").ToString());
Assert.Equal("nil", e.eval("(or (quote (nil nil nil nil)))").ToString()); Assert.Equal("nil", e.eval("(or (quote (nil nil nil nil)))").ToString());
Assert.Equal("t", e.eval("(any (lambda (x) (= x 2)) (list 1 2 3 4 5 6))").ToString());
Assert.Equal("nil", e.eval("(any (lambda (x) (= x 2)) (list 1 3 4 5 6))").ToString());
Assert.Equal("t", e.eval("(all (lambda (x) (= 1 (% x 2))) (list 1 3 5))").ToString());
Assert.Equal("nil", e.eval("(all (lambda (x) (= 1 (% x 2))) (list 1 3 4 5))").ToString());
} }
} }
} }