Skip to content

Commit 1c6d5af

Browse files
committed
Delete palet test cases
1 parent c29779d commit 1c6d5af

File tree

5 files changed

+3
-340
lines changed

5 files changed

+3
-340
lines changed

auto_editor/cmds/test.py

Lines changed: 3 additions & 166 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,9 @@
1212
from time import perf_counter
1313

1414
import av
15-
import numpy as np
1615
from av import AudioStream, VideoStream
1716

1817
from auto_editor.ffwrapper import FileInfo
19-
from auto_editor.lang.palet import Lexer, Parser, env, interpret
20-
from auto_editor.lang.stdenv import make_standard_env
21-
from auto_editor.lib.data_structs import Char
22-
from auto_editor.lib.err import MyError
2318
from auto_editor.utils.log import Log
2419
from auto_editor.vanparse import ArgumentParser
2520

@@ -29,13 +24,13 @@ class TestArgs:
2924
only: list[str] = field(default_factory=list)
3025
help: bool = False
3126
program: bool = False
32-
no_fail_fast: bool = False
27+
no_failfast: bool = False
3328
category: str = "cli"
3429

3530

3631
def test_options(parser: ArgumentParser) -> ArgumentParser:
3732
parser.add_argument("--only", "-n", nargs="*")
38-
parser.add_argument("--no-fail-fast", flag=True)
33+
parser.add_argument("--no-failfast", flag=True)
3934
parser.add_argument("--program", flag=True)
4035
parser.add_required(
4136
"category",
@@ -556,159 +551,6 @@ def test_audio_norm_ebu(self) -> None:
556551
["example.mp4"], ["--audio-normalize", "ebu:i=-5,lra=20,gain=5,tp=-1"]
557552
)
558553

559-
def palet_python_bridge(self):
560-
env.update(make_standard_env())
561-
562-
def cases(*cases: tuple[str, object]) -> None:
563-
for text, expected in cases:
564-
try:
565-
parser = Parser(Lexer("repl", text))
566-
env["timebase"] = Fraction(30)
567-
results = interpret(env, parser)
568-
except MyError as e:
569-
raise ValueError(f"{text}\nMyError: {e}")
570-
571-
result_val = results[-1]
572-
if isinstance(expected, np.ndarray):
573-
if not isinstance(result_val, np.ndarray):
574-
raise ValueError(f"{text}: Result is not an ndarray")
575-
if not np.array_equal(expected, result_val):
576-
raise ValueError(f"{text}: Numpy arrays don't match")
577-
elif expected != result_val:
578-
raise ValueError(f"{text}: Expected: {expected}, got {result_val}")
579-
580-
cases(
581-
("345", 345),
582-
("238.5", 238.5),
583-
("-34", -34),
584-
("-98.3", -98.3),
585-
("3sec", 90),
586-
("-3sec", -90),
587-
("0.2sec", 6),
588-
("(+ 4 3)", 7),
589-
("(+ 4 3 2)", 9),
590-
("(+ 10.5 3)", 13.5),
591-
("(- 4 3)", 1),
592-
("(- 3)", -3),
593-
("(- 10.5 3)", 7.5),
594-
("(* 11.5 3)", 34.5),
595-
("(/ 3/4 4)", Fraction(3, 16)),
596-
("(/ 5)", 0.2),
597-
("(/ 6 1)", 6.0),
598-
("30/1", Fraction(30)),
599-
("(pow 2 3)", 8),
600-
("(pow 4 0.5)", 2.0),
601-
("(abs 1.0)", 1.0),
602-
("(abs -1)", 1),
603-
("(bool? #t)", True),
604-
("(bool? #f)", True),
605-
("(bool? 0)", False),
606-
("(bool? 1)", False),
607-
("(bool? false)", True),
608-
("(int? 2)", True),
609-
("(int? 3.0)", False),
610-
("(int? #t)", False),
611-
("(int? #f)", False),
612-
("(int? 4/5)", False),
613-
('(int? "hello")', False),
614-
('(int? "3")', False),
615-
("(float? -23.4)", True),
616-
("(float? 3.0)", True),
617-
("(float? #f)", False),
618-
("(float? 4/5)", False),
619-
("(float? 21)", False),
620-
("(frac? 4/5)", True),
621-
("(frac? 3.4)", False),
622-
('(& "Hello" " World")', "Hello World"),
623-
('(define apple "Red Wood") apple', "Red Wood"),
624-
("(= 1 1.0)", True),
625-
("(= 1 2)", False),
626-
("(= 1)", True),
627-
("(+)", 0),
628-
("(*)", 1),
629-
('(define num 13) ; Set number to 13\n"Hello"', "Hello"),
630-
('(if #t "Hello" apple)', "Hello"),
631-
('(if #f mango "Hi")', "Hi"),
632-
('{if (= [+ 3 4] 7) "yes" "no"}', "yes"),
633-
("((if #t + -) 3 4)", 7),
634-
("((if #f + -) 3 4)", -1),
635-
("(when (positive? 3) 17)", 17),
636-
("(string)", ""),
637-
("(string #\\a)", "a"),
638-
("(string #\\a #\\b)", "ab"),
639-
("(string #\\a #\\b #\\c)", "abc"),
640-
(
641-
"(margin (bool-array 0 0 0 1 0 0 0) 0)",
642-
np.array([0, 0, 0, 1, 0, 0, 0], dtype=np.bool_),
643-
),
644-
(
645-
"(margin (bool-array 0 0 1 1 0 0 0) -2 2)",
646-
np.array([0, 0, 0, 0, 1, 1, 0], dtype=np.bool_),
647-
),
648-
("(equal? 3 3)", True),
649-
("(equal? 3 3.0)", False),
650-
('(equal? 16.3 "Editor")', False),
651-
("(equal? (bool-array 1 1 0) (bool-array 1 1 0))", True),
652-
("(equal? (bool-array 0 1 0) (bool-array 1 1 0))", False),
653-
("(equal? (bool-array 0 1 0) (bool-array 0 1 0 0))", False),
654-
("(equal? #\\a #\\a)", True),
655-
('(equal? "a" #\\a)', False),
656-
("(equal? (vector 1 2 3) (vector 1 2 3))", True),
657-
(
658-
"(or (bool-array 1 0 0) (bool-array 0 0 0 1))",
659-
np.array([1, 0, 0, 1], dtype=np.bool_),
660-
),
661-
("(len (vector 1 2 4))", 3),
662-
("(len #(1 2 4))", 3),
663-
("(len (bool-array 0 1 0))", 3),
664-
("(equal? (reverse #(0 1 2)) #(2 1 0))", True),
665-
("(equal? (reverse (vector 0 1 2)) (vector 2 1 0))", True),
666-
('(ref "Zyx" 1)', Char("y")),
667-
("(ref (vector 0.3 #\\a 2) 2)", 2),
668-
("(ref (range 0 10) 2)", 2),
669-
("((range 0 10) 2)", 2),
670-
("((vector 0.3 #\\a 17) 2)", 17),
671-
("(#(0.3 #\\a 17) 2)", 17),
672-
("(begin)", None),
673-
("(void)", None),
674-
("(begin (define r 10) (* 3.14 (* r r)))", 314.0),
675-
("#(-20dB 0dB 20dB)", [0.1, 1, 10]),
676-
("(define ca (lambda (r) (* 3.14 (* r r)))) (ca 5)", 78.5),
677-
(
678-
"(define ca (lambda (r) (void) (* 3.14 (* r r)))) (ca 5)",
679-
78.5,
680-
),
681-
("(define (my-pow2 a) (* a a)) (my-pow2 30)", 900),
682-
("(define (my-pow2 a) (void) (* a a)) (my-pow2 30)", 900),
683-
("(~a 3 4 'a)", "34a"),
684-
("(~s 3 4 'a)", "3 4 a"),
685-
("(~v 3 4 'a)", "3 4 'a"),
686-
("(define (my-func x) (define (inner) 4) (+ x (inner))) (my-func 16)", 20),
687-
("(define (text child ...) child)", None),
688-
("(text)", []),
689-
("(text 1)", [1]),
690-
("(text 2 1)", [2, 1]),
691-
("(text 3 2 1)", [3, 2, 1]),
692-
("((or/c 0 1) 1)", True),
693-
("((or/c 0 1) 2)", False),
694-
("((or/c 0 1) 1)", True),
695-
('((or/c 0 1 string?) "hello")', True),
696-
("((or/c 0 1 string?) 3)", False),
697-
('"hello".title', "Hello"),
698-
('"hello".upper', "HELLO"),
699-
('"heLlo".lower', "hello"),
700-
('(define s "hello")s.title', "Hello"),
701-
("(define v #(2 0 3 -4 -2 5 1 4)) v.sort", [-4, -2, 0, 1, 2, 3, 4, 5]),
702-
("(define v #(2 0 3 -4 -2 5 1 4)) v.sort! v", [-4, -2, 0, 1, 2, 3, 4, 5]),
703-
('#(#("sym" "symbol?") "bool?")', [["sym", "symbol?"], "bool?"]),
704-
)
705-
706-
def palet_scripts(self) -> None:
707-
self.raw(["palet", "resources/scripts/scope.pal"])
708-
self.raw(["palet", "resources/scripts/maxcut.pal"])
709-
self.raw(["palet", "resources/scripts/case.pal"])
710-
self.raw(["palet", "resources/scripts/testmath.pal"])
711-
712554

713555
def run_tests(tests: list[Callable], args: TestArgs) -> None:
714556
if args.only != []:
@@ -763,7 +605,7 @@ def timed_test(test_func):
763605
print(f"{msg}[\033[1;32mPASSED\033[0m]", flush=True)
764606
else:
765607
print(f"{msg}\033[1;31m[FAILED]\033[0m", flush=True)
766-
if args.no_fail_fast:
608+
if args.no_failfast:
767609
print(f"\n{exception}")
768610
else:
769611
print("")
@@ -790,11 +632,6 @@ def main(sys_args: list[str] | None = None) -> None:
790632
if callable(getattr(Runner, name)) and name not in ["main", "raw", "check"]
791633
}
792634

793-
if not args.program and args.category in {"palet", "all"}:
794-
tests.extend(
795-
[test_methods[name] for name in ["palet_python_bridge", "palet_scripts"]]
796-
)
797-
798635
if args.category in {"sub", "all"}:
799636
tests.extend(
800637
[test_methods[name] for name in ["info", "levels", "subdump", "desc"]]

resources/scripts/case.pal

Lines changed: 0 additions & 32 deletions
This file was deleted.

resources/scripts/maxcut.pal

Lines changed: 0 additions & 52 deletions
This file was deleted.

resources/scripts/scope.pal

Lines changed: 0 additions & 64 deletions
This file was deleted.

resources/scripts/testmath.pal

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)