(ns rustint.core-test (:require [clojure.test :refer :all] [rustint.core :refer :all])) (deftest pasar-a-float-test01 (testing "Test 01 pasar-a-float" (is (= (pasar-a-float 10) 10.0)) ) ) (deftest pasar-a-float-test02 (testing "Test 02 pasar-a-float" (is (= (pasar-a-float "10") 10.0)) ) ) (deftest pasar-a-float-test03 (testing "Test 03 pasar-a-float" (is (= (pasar-a-float 10.0) 10.0)) ) ) (deftest pasar-a-float-test04 (testing "Test 04 pasar-a-float" (is (= (pasar-a-float 'a) 'a)) ) ) (deftest pasar-a-float-test05 (testing "Test 05 pasar-a-float" (is (= (pasar-a-float [10]) [10])) ) ) (deftest pasar-a-int-test01 (testing "Test 01 int pasar-a-int" (is (= (pasar-a-int "10") 10)) ) ) (deftest pasar-a-int-test02 (testing "Test 02 int pasar-a-int" (is (= (pasar-a-int 10.0) 10)) ) ) (deftest pasar-a-int-test03 (testing "Test 03 int pasar-a-int" (is (= (pasar-a-int 10) 10)) ) ) (deftest pasar-a-int-test04 (testing "Test 04 int pasar-a-int" (is (= (pasar-a-int 'a) 'a)) ) ) (deftest pasar-a-int-test05 (testing "Test 05 int pasar-a-int" (is (= (pasar-a-int [10]) [10])) ) ) (deftest compatibles-test01 (testing "Test 01 compatibles?" (is (= (compatibles? 'i64 5) true)) ) ) (deftest compatibles-test02 (testing "Test 02 compatibles?" (is (= (compatibles? 'i64 5.0) false)) ) ) (deftest compatibles-test03 (testing "Test 03 compatibles?" (is (= (compatibles? 'i64 [5.0]) true)) ) ) (deftest compatibles-test04 (testing "Test 04 compatibles?" (is (= (compatibles? 'f64 5.0) true)) ) ) (deftest compatibles-test05 (testing "Test 05 compatibles?" (is (= (compatibles? 'String "Hola") true)) ) ) (deftest compatibles-test06 (testing "Test 06 compatibles?" (is (= (compatibles? 'bool true) true)) ) ) (deftest compatibles-test07 (testing "Test 07 compatibles?" (is (= (compatibles? 'bool 1) false)) ) ) (deftest compatibles-test08 (testing "Test 08 compatibles?" (is (= (compatibles? 'usize 1) true)) ) ) (deftest compatibles-test09 (testing "Test 09 compatibles?" (is (= (compatibles? 'char \a) true)) ) ) (deftest compatibles-test10 (testing "Test 10 compatibles?" (is (= (compatibles? 'char 'a) false)) ) ) (deftest compatibles-test11 (testing "Test 11 compatibles?" (is (= (compatibles? 'char ['a]) true)) ) ) (deftest dividir-test01 (testing "Test 01 dividir" (is (= (dividir 12 3) 4)) ) ) (deftest dividir-test02 (testing "Test 02 dividir" (is (= (dividir 12.0 3) 4.0)) ) ) (deftest dividir-test03 (testing "Test 03 dividir" (is (= (dividir 12 3.0) 4.0)) ) ) (deftest dividir-test04 (testing "Test 04h dividir" (is (= (dividir 12.0 3.0) 4.0)) ) ) (deftest dividir-test05 (testing "Test 05 dividir" (is (= (dividir 1 2) 0)) ) ) (deftest dividir-test06 (testing "Test 06 dividir" (is (= (dividir 1 2.0) 0.5)) ) ) (deftest identificador-test01 (testing "Test 01 identificador" (is (= (identificador? 'boolean) true)) ) ) (deftest identificador-test02 (testing "Test 02 identificador" (is (= (identificador? 'bool) false)) ) ) (deftest identificador-test03 (testing "Test 03 identificador" (is (= (identificador? 'e120) true)) ) ) (deftest identificador-test04 (testing "Test 04 identificador" (is (= (identificador? '12e0) false)) ) ) (deftest palabra-reservada-test01 (testing "Test 01 palabra reservada" (is (= (palabra-reservada? 'while) true)) ) ) (deftest palabra-reservada-test02 (testing "Test 02 palabra reservada" (is (= (palabra-reservada? 'until) false)) ) ) (deftest palabra-reservada-test03 (testing "Test 03 palabra reservada" (is (= (palabra-reservada? 13) false)) ) ) (deftest dump-01 (testing "Test 01 dump" (let [ printed (with-out-str (dump '[[POPREF 2] [PUSHFI 2] MUL [PUSHFI 1] ADD NEG])) ] (is (= printed "0 [POPREF 2]\n1 [PUSHFI 2]\n2 MUL\n3 [PUSHFI 1]\n4 ADD\n5 NEG\n" )) ) ) ) (deftest dump-01-nil (testing "Test 01 dump nil" (is (nil? (dump '[[POPREF 2] [PUSHFI 2] MUL [PUSHFI 1] ADD NEG]))) ) ) (deftest dump-02 (testing "Test 02 dump" (let [ printed (with-out-str (dump '[HLT])) ] (is (= printed "0 HLT\n" )) ) ) ) (deftest dump-02-nil (testing "Test 02 dump nil" (is (nil? (dump '[HLT]))) ) ) (deftest dump-03 (testing "Test 03 dump" (let [ printed (with-out-str (dump nil)) ] (is (= printed "0 nil\n" )) ) ) ) (deftest dump-03-nil (testing "Test 03 dump nil" (is (nil? (dump nil))) ) ) (deftest convertir-formato-impresion-01 (testing "Test 01 convertir-formato-impresion" (is (= (convertir-formato-impresion '("Hola, mundo!")) '("Hola, mundo!") ) ) ) ) (deftest convertir-formato-impresion-02 (testing "Test 02 convertir-formato-impresion" (is (= (convertir-formato-impresion '("Hola, mundo 2!")) '("Hola, mundo 2!") ) ) ) ) (deftest convertir-formato-impresion-03 (testing "Test 03 convertir-formato-impresion" (is (= (convertir-formato-impresion '("Hola, mundo {}!" 2)) '("Hola, mundo %d!" 2) ) ) ) ) (deftest convertir-formato-impresion-04 (testing "Test 04 convertir-formato-impresion" (is (= (convertir-formato-impresion '("Hola, mundo {}!" 2.0)) '("Hola, mundo %.0f!" 2.0) ) ) ) ) (deftest convertir-formato-impresion-05 (testing "Test 05 convertir-formato-impresion" (is (= (convertir-formato-impresion '("Hola, mundo {}!" "2")) '("Hola, mundo %s!" "2") ) ) ) ) (deftest convertir-formato-impresion-06 (testing "Test 06 convertir-formato-impresion" (is (= (convertir-formato-impresion '("Hola, mundo {} {} {}!" 2 2.0 "2")) '("Hola, mundo %d %.0f %s!" 2 2.0 "2") ) ) ) ) (deftest convertir-formato-impresion-07 (testing "Test 07 convertir-formato-impresion" (is (= (convertir-formato-impresion '("Hola, mundo {:.8}!" 2.0)) '("Hola, mundo %.8f!" 2.0) ) ) ) ) (deftest convertir-formato-impresion-08 (testing "Test 08 convertir-formato-impresion" (is (= (convertir-formato-impresion '("- My name is {}, James {}.\n- Hello, {}{}{}!" "Bond" "Bond" 0 0 7)) '("- My name is %s, James %s.\n- Hello, %d%d%d!" "Bond" "Bond" 0 0 7) ) ) ) ) (deftest convertir-formato-impresion-09 (testing "Test 09 convertir-formato-impresion" (is (= (convertir-formato-impresion '("{} elevado a la {} es\t{}" 2.0 2 4.0)) '("%.0f elevado a la %d es\t%.0f" 2.0 2 4.0) ) ) ) ) (deftest convertir-formato-impresion-10 (testing "Test 10 convertir-formato-impresion" (is (= (convertir-formato-impresion '("Las raices cuadradas de {} son +{:.8} y -{:.8}" 4.0 1.999999999985448 1.999999999985448)) '("Las raices cuadradas de %.0f son +%.8f y -%.8f" 4.0 1.999999999985448 1.999999999985448) ) ) ) ) (deftest get-rust-formatters-01 (testing "Test 01 get-rust-formatters" (is (= (get-rust-formatters "Hola, Mundo!") '() ) ) ) ) (deftest get-rust-formatters-02 (testing "Test 02 get-rust-formatters" (is (= (get-rust-formatters "- My name is {}, James {}.\n- Hello, {}{}{}!") '(nil nil nil nil nil) ) ) ) ) (deftest get-rust-formatters-03 (testing "Test 03 get-rust-formatters" (is (= (get-rust-formatters "{} elevado a la {} es\t{}") '(nil nil nil) ) ) ) ) (deftest get-rust-formatters-04 (testing "Test 04 get-rust-formatters" (is (= (get-rust-formatters "Las raices cuadradas de {} son +{:.8} y -{:.8}") '(nil ".8" ".8") ) ) ) ) (deftest test-especificador-formato-01 (testing "Test 01 especificador formato" (is (= (especificador-formato "Bond" nil) "%s" ) ) ) ) (deftest test-especificador-formato-02 (testing "Test 02 especificador formato" (is (= (especificador-formato 0 nil) "%d" ) ) ) ) (deftest test-especificador-formato-03 (testing "Test 03 especificador formato" (is (= (especificador-formato 2.0 nil) "%.0f" ) ) ) ) (deftest test-especificador-formato-04 (testing "Test 04 especificador formato" (is (= (especificador-formato 2.0 ".4") "%.4f" ) ) ) ) (deftest test-especificador-formato-05 (testing "Test 05 especificador formato" (is (= (especificador-formato 2.0 ".8") "%.8f" ) ) ) ) (deftest test-listar-01 (testing "Test 01 listar" (let [ printed (with-out-str (listar (list 'fn 'main (symbol "(") (symbol ")") (symbol "{") 'println! (symbol "(") "Hola, mundo!" (symbol ")") (symbol "}")))) ] (is (= printed "fn main ( )\n{\n println! ( \"Hola, mundo!\" )\n}" ) ) ) ) ) (deftest test-ya-declarado-localmente-01 (testing "Test 01 ya-declarado-localmente?" (is (= (ya-declarado-localmente? 'Write [ [0] [ ['io ['lib '()] 0] ['Write ['lib '()] 0] ['entero_a_hexa ['fn [(list ['n (symbol ":") 'i64]) 'String]] 2] ] ] ) true)) ) ) (deftest test-ya-declarado-localmente-02 (testing "Test 02 ya-declarado-localmente?" (is (= (ya-declarado-localmente? 'Read [ [0] [ ['io ['lib '()] 0] ['Write ['lib '()] 0] ['entero_a_hexa ['fn [(list ['n (symbol ":") 'i64]) 'String]] 2] ] ] ) false)) ) ) (deftest test-ya-declarado-localmente-03 (testing "Test 03 ya-declarado-localmente?" (is (= (ya-declarado-localmente? 'Write [ [0 1] [ ['io ['lib '()] 0] ['Write ['lib '()] 0] ['entero_a_hexa ['fn [(list ['n (symbol ":") 'i64]) 'String]] 2] ] ] ) true)) ) ) (deftest test-ya-declarado-localmente-04 (testing "Test 04 ya-declarado-localmente?" (is (= (ya-declarado-localmente? 'Write [ [0 2] [ ['io ['lib '()] 0] ['Write ['lib '()] 0] ['entero_a_hexa ['fn [(list ['n (symbol ":") 'i64]) 'String]] 2] ] ] ) false)) ) ) (deftest test-buscar-tipo-de-retorno-01 (testing "Test 01 buscar-tipo-de-retorno" (is (= (buscar-tipo-de-retorno [ (symbol ";") (list 'println! (symbol "(") "La suma de 5 mas 7 es {}" (symbol ",") 'suma (symbol "(") 5 (symbol ",") 7 (symbol ")") (symbol ")") (symbol ";") (symbol "}")) ['fn 'suma (symbol "(") 'x (symbol ":") 'i64 (symbol ",") 'y (symbol ":") 'i64 (symbol ")") (symbol "->") 'i64 (symbol "{") 'x '+ 'y (symbol "}") 'fn 'main (symbol "(") (symbol ")") (symbol "{") 'suma (symbol "(") 5 (symbol ",") 7 (symbol ")")] :sin-errores [ [0 2] [ ['suma ['fn [(list ['x (symbol ":") 'i64] ['y (symbol ":") 'i64]) 'i64]] 2] ['main ['fn [() ()]] 8] ] ] 0 [['CAL 8] 'HLT ['POPARG 1] ['POPARG 0] ['PUSHFM 0] ['PUSHFM 1] 'ADD 'RET ['PUSHFI 5] ['PUSHFI 7] ['CAL 2]] [[2 ['i64 nil] ['i64 nil]] [8]] ] 2 ) 'i64 ) ) ) ) (deftest test-buscar-tipo-de-retorno-02 (testing "Test 02 buscar-tipo-de-retorno" (is (= (buscar-tipo-de-retorno [ (symbol ";") (list 'println! (symbol "(") "La suma de 5 mas 7 es {}" (symbol ",") 'suma (symbol "(") 5 (symbol ",") 7 (symbol ")") (symbol ")") (symbol ";") (symbol "}")) ['fn 'suma (symbol "(") 'x (symbol ":") 'i64 (symbol ",") 'y (symbol ":") 'i64 (symbol ")") (symbol "->") 'i64 (symbol "{") 'x '+ 'y (symbol "}") 'fn 'main (symbol "(") (symbol ")") (symbol "{") 'suma (symbol "(") 5 (symbol ",") 7 (symbol ")")] :sin-errores [ [0 2] [ ['suma ['fn [(list ['x (symbol ":") 'i64] ['y (symbol ":") 'i64]) 'i64]] 2] ['main ['fn [() ()]] 8] ] ] 0 [['CAL 8] 'HLT ['POPARG 1] ['POPARG 0] ['PUSHFM 0] ['PUSHFM 1] 'ADD 'RET ['PUSHFI 5] ['PUSHFI 7] ['CAL 2]] [[2 ['i64 nil] ['i64 nil]] [8]] ] 8 ) '() ) ) ) ) (deftest test-buscar-tipo-de-retorno-03 (testing "Test 03 buscar-tipo-de-retorno" (is (= (buscar-tipo-de-retorno [ (symbol ";") (list 'println! (symbol "(") "La suma de 5 mas 7 es {}" (symbol ",") 'suma (symbol "(") 5 (symbol ",") 7 (symbol ")") (symbol ")") (symbol ";") (symbol "}")) ['fn 'suma (symbol "(") 'x (symbol ":") 'i64 (symbol ",") 'y (symbol ":") 'i64 (symbol ")") (symbol "->") 'i64 (symbol "{") 'x '+ 'y (symbol "}") 'fn 'main (symbol "(") (symbol ")") (symbol "{") 'suma (symbol "(") 5 (symbol ",") 7 (symbol ")")] :sin-errores [ [0 2] [ ['suma ['fn [(list ['x (symbol ":") 'i64] ['y (symbol ":") 'i64]) 'i64]] 2] ['main ['fn [() ()]] 8] ] ] 0 [['CAL 8] 'HLT ['POPARG 1] ['POPARG 0] ['PUSHFM 0] ['PUSHFM 1] 'ADD 'RET ['PUSHFI 5] ['PUSHFI 7] ['CAL 2]] [[2 ['i64 nil] ['i64 nil]] [8]] ] 1 ) nil ) ) ) ) (deftest test-cargar-const-en-tabla-01 (testing "Test 01 cargar-const-en-tabla" (is (= (cargar-const-en-tabla [ (symbol ";") ; simb-actual (list 'fn 'main (symbol "(") (symbol ")") (symbol "{") 'println! (symbol "(") "{}" (symbol ",") 'TRES (symbol ")") (symbol "}")) ; simb-no-parseados-aun ['use 'std (symbol "::") 'io (symbol ";") 'const 'TRES (symbol ":") 'i64 (symbol "=") 3] ; simb-ya-parseados 8 ; estado [[0] [['io ['lib '()] 0]]] ; contexto 0 ; prox-var [['CAL 0] 'HLT] ; bytecode [] ; mapa-regs-de-act ]) [ (symbol ";") (list 'fn 'main (symbol "(") (symbol ")") (symbol "{") 'println! (symbol "(") "{}" (symbol ",") 'TRES (symbol ")") (symbol "}")) ['use 'std (symbol "::") 'io (symbol ";") 'const 'TRES (symbol ":") 'i64 (symbol "=") 3] 8 [[0] [['io ['lib '()] 0]]] 0 [['CAL 0] 'HLT] [] ] ) ) ) ) (deftest test-cargar-const-en-tabla-02 (testing "Test 02 cargar-const-en-tabla" (is (= (cargar-const-en-tabla [ (symbol ";") (list 'fn 'main (symbol "(") (symbol ")") (symbol "{") 'println! (symbol "(") "{}" (symbol ",") 'TRES (symbol ")") (symbol "}")) ['use 'std (symbol "::") 'io (symbol ";") 'const 'TRES (symbol ":") 'i64 (symbol "=") 3] :sin-errores [[0] [ ['io ['lib '()] 0] ] ] 0 [['CAL 0] 'HLT] [] ] ) [ (symbol ";") (list 'fn 'main (symbol "(") (symbol ")") (symbol "{") 'println! (symbol "(") "{}" (symbol ",") 'TRES (symbol ")") (symbol "}")) ['use 'std (symbol "::") 'io (symbol ";") 'const 'TRES (symbol ":") 'i64 (symbol "=") 3] :sin-errores [[0] [ ['io ['lib '()] 0] ['TRES ['const 'i64] 3] ] ] 0 [['CAL 0] 'HLT] [] ] ) ) ) ) (deftest test-inicializar-contexto-local-01 (testing "Test 01 inicializar-contexto-local" (is (= (inicializar-contexto-local [ (symbol "{") (list 'let 'x (symbol ":") 'i64 (symbol "=") 10 (symbol ";") 'println! (symbol "(") "{}" (symbol ",") 'x (symbol ")") (symbol "}")) ['fn 'main (symbol "(") (symbol ")")] 8 [[0] [['main ['fn [() ()]] 2]]] 0 [['CAL 2] 'HLT] [] ] ) [ (symbol "{") (list 'let 'x (symbol ":") 'i64 (symbol "=") 10 (symbol ";") 'println! (symbol "(") "{}" (symbol ",") 'x (symbol ")") (symbol "}")) ['fn 'main (symbol "(") (symbol ")")] 8 [[0] [['main ['fn [() ()]] 2]]] 0 [['CAL 2] 'HLT] [] ] )) ) ) (deftest test-inicializar-contexto-local-02 (testing "Test 02 inicializar-contexto-local" (is (= (inicializar-contexto-local [ (symbol "{") (list 'let 'x (symbol ":") 'i64 (symbol "=") 10 (symbol ";") 'println! (symbol "(") "{}" (symbol ",") 'x (symbol ")") (symbol "}")) ['fn 'main (symbol "(") (symbol ")")] :sin-errores [[0] [['main ['fn [() ()]] 2]]] 0 [['CAL 2] 'HLT] [] ] ) [ (symbol "{") (list 'let 'x (symbol ":") 'i64 (symbol "=") 10 (symbol ";") 'println! (symbol "(") "{}" (symbol ",") 'x (symbol ")") (symbol "}")) ['fn 'main (symbol "(") (symbol ")")] :sin-errores [[0 1] [['main ['fn [() ()]] 2]]] 0 [['CAL 2] 'HLT] [] ] ) ) ) ) (deftest test-restaurar-contexto-anterior-01 (testing "Test 01 restaurar-contexto-anterior" (is (= (restaurar-contexto-anterior [ 'EOF () ['fn 'main (symbol "(") (symbol ")") (symbol "{") 'let 'x (symbol ":") 'i64 (symbol "=") 10 (symbol ";") 'let 'y (symbol ":") 'i64 (symbol "=") 20 (symbol ";") 'println! (symbol "(") "{}" (symbol ",") 'x '+ 'y (symbol ")") (symbol "}")] 8 [[0 1] [['main ['fn [() ()]] 2] ['x ['var-inmut 'i64] 0] ['y ['var-inmut 'i64] 1]]] 2 [['CAL 2] 'HLT ['PUSHFI 10] ['POP 0] ['PUSHFI 20] ['POP 1] ['PUSHFI "{}"] ['PUSHFM 0] ['PUSHFM 1] 'ADD ['PUSHFI 2] 'OUT 'NL] [[2 ['i64 nil] ['i64 nil]]] ] ) [ 'EOF () ['fn 'main (symbol "(") (symbol ")") (symbol "{") 'let 'x (symbol ":") 'i64 (symbol "=") 10 (symbol ";") 'let 'y (symbol ":") 'i64 (symbol "=") 20 (symbol ";") 'println! (symbol "(") "{}" (symbol ",") 'x '+ 'y (symbol ")") (symbol "}")] 8 [[0 1] [['main ['fn [() ()]] 2] ['x ['var-inmut 'i64] 0] ['y ['var-inmut 'i64] 1]]] 2 [['CAL 2] 'HLT ['PUSHFI 10] ['POP 0] ['PUSHFI 20] ['POP 1] ['PUSHFI "{}"] ['PUSHFM 0] ['PUSHFM 1] 'ADD ['PUSHFI 2] 'OUT 'NL] [[2 ['i64 nil] ['i64 nil]]] ] )) ) ) (deftest test-restaurar-contexto-anterior-02 (testing "Test 02 restaurar-contexto-anterior" (is (= (restaurar-contexto-anterior [ 'EOF () ['fn 'main (symbol "(") (symbol ")") (symbol "{") 'let 'x (symbol ":") 'i64 (symbol "=") 10 (symbol ";") 'let 'y (symbol ":") 'i64 (symbol "=") 20 (symbol ";") 'println! (symbol "(") "{}" (symbol ",") 'x '+ 'y (symbol ")") (symbol "}")] :sin-errores [[0 1] [['main ['fn [() ()]] 2] ['x ['var-inmut 'i64] 0] ['y ['var-inmut 'i64] 1]]] 2 [['CAL 2] 'HLT ['PUSHFI 10] ['POP 0] ['PUSHFI 20] ['POP 1] ['PUSHFI "{}"] ['PUSHFM 0] ['PUSHFM 1] 'ADD ['PUSHFI 2] 'OUT 'NL] [[2 ['i64 nil] ['i64 nil]]] ] ) [ 'EOF () ['fn 'main (symbol "(") (symbol ")") (symbol "{") 'let 'x (symbol ":") 'i64 (symbol "=") 10 (symbol ";") 'let 'y (symbol ":") 'i64 (symbol "=") 20 (symbol ";") 'println! (symbol "(") "{}" (symbol ",") 'x '+ 'y (symbol ")") (symbol "}")] :sin-errores [[0] [['main ['fn [() ()]] 2]]] 2 [['CAL 2] 'HLT ['PUSHFI 10] ['POP 0] ['PUSHFI 20] ['POP 1] ['PUSHFI "{}"] ['PUSHFM 0] ['PUSHFM 1] 'ADD ['PUSHFI 2] 'OUT 'NL] [[2 ['i64 nil] ['i64 nil]]] ] )) ) ) (deftest test-cargar-en-reg-dest-01 (testing "Test 01 cargar-en-reg-dest" (is (= (cargar-en-reg-dest [[['String "2"] ['i64 6] ['i64 2] ['i64 2] ['i64 2]] [['i64 6] ['i64 2] ['i64 [0 3]] ['i64 [0 4]] ['i64 2] ['i64 2]]] [0 4] 'i64 0) [[['String "2"] ['i64 6] ['i64 2] ['i64 2] ['i64 0]] [['i64 6] ['i64 2] ['i64 [0 3]] ['i64 [0 4]] ['i64 2] ['i64 2]]] )) ) ) (deftest test-cargar-en-reg-dest-02 (testing "Test 02 cargar-en-reg-dest" (is (= (cargar-en-reg-dest [[['String "2"] ['i64 6] ['i64 2] ['i64 2] ['i64 0]] [['i64 6] ['i64 2] ['i64 [0 3]] ['i64 [0 4]] ['i64 2] ['i64 2]]] [0 3] 'f64 3) [[['String "2"] ['i64 6] ['i64 2] ['f64 3] ['i64 0]] [['i64 6] ['i64 2] ['i64 [0 3]] ['i64 [0 4]] ['i64 2] ['i64 2]]] )) ) ) (deftest test-cargar-en-ult-reg-01 (testing "Test 01 cargar-en-ult-reg" (is (= (cargar-en-ult-reg [[['String "2"] ['i64 6] ['i64 2] ['i64 3] ['i64 0]] [['i64 nil] ['i64 nil]]] 1 'i64 0) [[['String "2"] ['i64 6] ['i64 2] ['i64 3] ['i64 0]] [['i64 nil] ['i64 0]]] )) ) ) (deftest test-cargar-en-ult-reg-02 (testing "Test 02 cargar-en-ult-reg" (is (= (cargar-en-ult-reg [[['String "2"] ['i64 6] ['i64 2] ['i64 3] ['i64 0]] [['i64 nil] ['i64 0]]] 0 'f64 3) [[['String "2"] ['i64 6] ['i64 2] ['i64 3] ['i64 0]] [['f64 3] ['i64 0]]] )) ) ) (deftest test-fixup-01 (testing "Test 01 fixup" (is (= (fixup [ (symbol "{") (list 'x '= 20 (symbol ";") (symbol "}") (symbol ";") 'println! (symbol "(") "{}" (symbol ",") 'x (symbol ")") (symbol "}")) ['fn 'main (symbol "(") (symbol ")") (symbol "{") 'let 'x (symbol ":") 'i64 (symbol ";") 'if false (symbol "{") 'x '= 10 (symbol ";") (symbol "}") 'else] 8 [[0 1 2] [['main ['fn [() ()]] 2] ['x ['var-inmut 'i64] 0]]] 1 [['CAL 2] 'HLT ['PUSHFI false] ['JC 5] ['JMP '?] ['PUSHFI 10] ['POP 0] ['JMP '?]] [[2 ['i64 nil]]] ] 4) [ (symbol "{") (list 'x '= 20 (symbol ";") (symbol "}") (symbol ";") 'println! (symbol "(") "{}" (symbol ",") 'x (symbol ")") (symbol "}")) ['fn 'main (symbol "(") (symbol ")") (symbol "{") 'let 'x (symbol ":") 'i64 (symbol ";") 'if false (symbol "{") 'x '= 10 (symbol ";") (symbol "}") 'else] 8 [[0 1 2] [['main ['fn [() ()]] 2] ['x ['var-inmut 'i64] 0]]] 1 [['CAL 2] 'HLT ['PUSHFI false] ['JC 5] ['JMP '?] ['PUSHFI 10] ['POP 0] ['JMP '?]] [[2 ['i64 nil]]] ] )) ) ) (deftest test-fixup-02 (testing "Test 02 fixup" (is (= (fixup [ (symbol "{") (list 'x '= 20 (symbol ";") (symbol "}") (symbol ";") 'println! (symbol "(") "{}" (symbol ",") 'x (symbol ")") (symbol "}")) ['fn 'main (symbol "(") (symbol ")") (symbol "{") 'let 'x (symbol ":") 'i64 (symbol ";") 'if false (symbol "{") 'x '= 10 (symbol ";") (symbol "}") 'else] :sin-errores [[0 1 2] [['main ['fn [() ()]] 2] ['x ['var-inmut 'i64] 0]]] 1 [['CAL 2] 'HLT ['PUSHFI false] ['JC 5] ['JMP '?] ['PUSHFI 10] ['POP 0] ['JMP '?]] [[2 ['i64 nil]]] ] 4) [ (symbol "{") (list 'x '= 20 (symbol ";") (symbol "}") (symbol ";") 'println! (symbol "(") "{}" (symbol ",") 'x (symbol ")") (symbol "}")) ['fn 'main (symbol "(") (symbol ")") (symbol "{") 'let 'x (symbol ":") 'i64 (symbol ";") 'if false (symbol "{") 'x '= 10 (symbol ";") (symbol "}") 'else] :sin-errores [[0 1 2] [['main ['fn [() ()]] 2] ['x ['var-inmut 'i64] 0]]] 1 [['CAL 2] 'HLT ['PUSHFI false] ['JC 5] ['JMP 8] ['PUSHFI 10] ['POP 0] ['JMP '?]] [[2 ['i64 nil]]] ] )) ) )