Skip to content

Commit d3c5efa

Browse files
CopilotUltiRequiem
andcommitted
Add test step to CI and fix code formatting
Co-authored-by: UltiRequiem <[email protected]>
1 parent 12fe053 commit d3c5efa

File tree

8 files changed

+81
-73
lines changed

8 files changed

+81
-73
lines changed

.github/workflows/ci.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,9 @@ jobs:
2525
with:
2626
command: fmt
2727
args: --all -- --check
28+
29+
- name: Run tests
30+
uses: actions-rs/cargo@v1
31+
with:
32+
command: test
33+
args: --all

rustico/tests/basic_syntax.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ fn test_basic_function() {
77
retorna 42;
88
}
99
}
10-
10+
1111
assert_eq!(prueba(), 42);
1212
}
1313

@@ -21,7 +21,7 @@ fn test_let_and_mut() {
2121
retorna y;
2222
}
2323
}
24-
24+
2525
assert_eq!(prueba_variables(), 15);
2626
}
2727

@@ -36,7 +36,7 @@ fn test_if_else() {
3636
}
3737
}
3838
}
39-
39+
4040
assert_eq!(prueba_condicional(15), 1);
4141
assert_eq!(prueba_condicional(5), 0);
4242
}
@@ -52,7 +52,7 @@ fn test_match() {
5252
}
5353
}
5454
}
55-
55+
5656
assert_eq!(prueba_macheo(1), 10);
5757
assert_eq!(prueba_macheo(2), 20);
5858
assert_eq!(prueba_macheo(99), 0);
@@ -69,7 +69,7 @@ fn test_for_loop() {
6969
retorna suma;
7070
}
7171
}
72-
72+
7373
assert_eq!(prueba_bucle_para(), 10);
7474
}
7575

@@ -84,7 +84,7 @@ fn test_while_loop() {
8484
retorna contador;
8585
}
8686
}
87-
87+
8888
assert_eq!(prueba_mientras(), 5);
8989
}
9090

@@ -102,6 +102,6 @@ fn test_loop_and_break() {
102102
retorna x;
103103
}
104104
}
105-
105+
106106
assert_eq!(prueba_bucle_infinito(), 10);
107107
}

rustico/tests/keyword_alternatives.rs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ fn test_function_alternatives() {
55
rustico::rustico! {
66
// función with tilde
77
función con_tilde() -> e32 { 1 }
8-
8+
99
// funcion without tilde
1010
funcion sin_tilde() -> e32 { 2 }
1111
}
12-
12+
1313
assert_eq!(con_tilde(), 1);
1414
assert_eq!(sin_tilde(), 2);
1515
}
@@ -21,13 +21,13 @@ fn test_let_alternatives() {
2121
deja x = 10;
2222
x
2323
}
24-
24+
2525
función prueba_sea() -> e32 {
2626
sea y = 20;
2727
y
2828
}
2929
}
30-
30+
3131
assert_eq!(prueba_deja(), 10);
3232
assert_eq!(prueba_sea(), 20);
3333
}
@@ -38,12 +38,12 @@ fn test_return_alternatives() {
3838
función usa_retorna() -> e32 {
3939
retorna 1;
4040
}
41-
41+
4242
función usa_devuelve() -> e32 {
4343
devuelve 2;
4444
}
4545
}
46-
46+
4747
assert_eq!(usa_retorna(), 1);
4848
assert_eq!(usa_devuelve(), 2);
4949
}
@@ -61,7 +61,7 @@ fn test_loop_alternatives() {
6161
}
6262
x
6363
}
64-
64+
6565
función usa_ciclo() -> e32 {
6666
sea mutable y = 0;
6767
ciclo {
@@ -73,7 +73,7 @@ fn test_loop_alternatives() {
7373
y
7474
}
7575
}
76-
76+
7777
assert_eq!(usa_bucle(), 5);
7878
assert_eq!(usa_ciclo(), 3);
7979
}
@@ -84,16 +84,16 @@ fn test_unwrap_alternatives() {
8484
función usa_pelar() -> e32 {
8585
Alguno(10).pelar()
8686
}
87-
87+
8888
función usa_desenvolver() -> e32 {
8989
Alguno(20).desenvolver()
9090
}
91-
91+
9292
función usa_destapar() -> e32 {
9393
Alguno(30).destapar()
9494
}
9595
}
96-
96+
9797
assert_eq!(usa_pelar(), 10);
9898
assert_eq!(usa_desenvolver(), 20);
9999
assert_eq!(usa_destapar(), 30);
@@ -105,24 +105,24 @@ fn test_self_alternatives() {
105105
estructura UsaYo {
106106
valor: e32,
107107
}
108-
108+
109109
implementa UsaYo {
110110
función con_yo(&yo) -> e32 {
111111
yo.valor
112112
}
113113
}
114-
114+
115115
estructura UsaMismo {
116116
valor: e32,
117117
}
118-
118+
119119
implementa UsaMismo {
120120
función con_mismo(&mismo) -> e32 {
121121
mismo.valor
122122
}
123123
}
124124
}
125-
125+
126126
let obj1 = UsaYo { valor: 100 };
127127
let obj2 = UsaMismo { valor: 200 };
128128
assert_eq!(obj1.con_yo(), 100);
@@ -135,7 +135,7 @@ fn test_pub_alternatives() {
135135
púb función con_tilde() -> e32 { 1 }
136136
publico función sin_tilde() -> e32 { 2 }
137137
}
138-
138+
139139
assert_eq!(con_tilde(), 1);
140140
assert_eq!(sin_tilde(), 2);
141141
}
@@ -149,15 +149,15 @@ fn test_match_alternatives() {
149149
_ => 0,
150150
}
151151
}
152-
152+
153153
función usa_encaja(x: e32) -> e32 {
154154
encaja x {
155155
2 => 20,
156156
_ => 0,
157157
}
158158
}
159159
}
160-
160+
161161
assert_eq!(usa_machea(1), 10);
162162
assert_eq!(usa_encaja(2), 20);
163163
}
@@ -172,7 +172,7 @@ fn test_for_alternatives() {
172172
}
173173
suma
174174
}
175-
175+
176176
función usa_por() -> e32 {
177177
sea mutable suma = 0;
178178
por i de 0..3 {
@@ -181,7 +181,7 @@ fn test_for_alternatives() {
181181
suma
182182
}
183183
}
184-
184+
185185
assert_eq!(usa_para(), 3);
186186
assert_eq!(usa_por(), 3);
187187
}
@@ -192,12 +192,12 @@ fn test_expect_alternatives() {
192192
función usa_confia() -> e32 {
193193
Alguno(42).confia("debe existir")
194194
}
195-
195+
196196
función usa_asume() -> e32 {
197197
Alguno(43).asume("debe existir")
198198
}
199199
}
200-
200+
201201
assert_eq!(usa_confia(), 42);
202202
assert_eq!(usa_asume(), 43);
203203
}

rustico/tests/option_result.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ fn test_option_some() {
77
Alguno(42)
88
}
99
}
10-
10+
1111
assert_eq!(retornar_alguno(), Some(42));
1212
}
1313

@@ -18,7 +18,7 @@ fn test_option_none() {
1818
Ninguno
1919
}
2020
}
21-
21+
2222
assert_eq!(retornar_ninguno(), None);
2323
}
2424

@@ -30,7 +30,7 @@ fn test_option_unwrap() {
3030
opt.pelar()
3131
}
3232
}
33-
33+
3434
assert_eq!(pelar_opcion(), 100);
3535
}
3636

@@ -42,7 +42,7 @@ fn test_option_unwrap_or() {
4242
opt.pelar_o(50)
4343
}
4444
}
45-
45+
4646
assert_eq!(pelar_o_defecto(), 50);
4747
}
4848

@@ -53,7 +53,7 @@ fn test_result_ok() {
5353
Bien(42)
5454
}
5555
}
56-
56+
5757
assert_eq!(retornar_bien(), Ok(42));
5858
}
5959

@@ -64,7 +64,7 @@ fn test_result_err() {
6464
Error(Cadena::desde("falló"))
6565
}
6666
}
67-
67+
6868
assert_eq!(retornar_error(), Err(String::from("falló")));
6969
}
7070

@@ -76,7 +76,7 @@ fn test_result_unwrap() {
7676
res.pelar()
7777
}
7878
}
79-
79+
8080
assert_eq!(pelar_resultado(), 200);
8181
}
8282

@@ -88,7 +88,7 @@ fn test_result_expect() {
8888
res.confia("debería funcionar")
8989
}
9090
}
91-
91+
9292
assert_eq!(confiar_resultado(), 300);
9393
}
9494

@@ -102,7 +102,7 @@ fn test_option_match() {
102102
}
103103
}
104104
}
105-
105+
106106
assert_eq!(procesar_opcion(Some(10)), 20);
107107
assert_eq!(procesar_opcion(None), 0);
108108
}
@@ -117,7 +117,7 @@ fn test_result_match() {
117117
}
118118
}
119119
}
120-
120+
121121
assert_eq!(procesar_resultado(Ok(42)), 42);
122122
assert_eq!(procesar_resultado(Err(String::from("error"))), -1);
123123
}

rustico/tests/stdlib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
fn test_std_imports() {
55
rustico::rustico! {
66
usar estd::colecciones::Diccionario;
7-
7+
88
función crear_diccionario() -> Diccionario<Cadena, e32> {
99
sea mutable mapa = Diccionario::nuevo();
1010
mapa.insertar(Cadena::desde("uno"), 1);
1111
mapa.insertar(Cadena::desde("dos"), 2);
1212
mapa
1313
}
1414
}
15-
15+
1616
let mapa = crear_diccionario();
1717
assert_eq!(mapa.get("uno"), Some(&1));
1818
assert_eq!(mapa.get("dos"), Some(&2));
@@ -22,7 +22,7 @@ fn test_std_imports() {
2222
fn test_hashset_imports() {
2323
rustico::rustico! {
2424
usar estd::colecciones::Conjunto;
25-
25+
2626
función crear_conjunto() -> Conjunto<e32> {
2727
sea mutable set = Conjunto::nuevo();
2828
set.insertar(1);
@@ -31,7 +31,7 @@ fn test_hashset_imports() {
3131
set
3232
}
3333
}
34-
34+
3535
let set = crear_conjunto();
3636
assert!(set.contains(&1));
3737
assert!(set.contains(&2));
@@ -50,7 +50,7 @@ fn test_vec_type() {
5050
v
5151
}
5252
}
53-
53+
5454
let v = crear_vector();
5555
assert_eq!(v.len(), 3);
5656
assert_eq!(v[0], 1);
@@ -65,7 +65,7 @@ fn test_box_type() {
6565
Caja::nuevo(42)
6666
}
6767
}
68-
68+
6969
let boxed = crear_caja();
7070
assert_eq!(*boxed, 42);
7171
}

0 commit comments

Comments
 (0)