change headers

This commit is contained in:
Folkert 2021-03-01 15:15:05 +01:00
parent 3e3fe4fc7a
commit ef362ada26
11 changed files with 4402 additions and 4487 deletions

View file

@ -1,22 +1,12 @@
#[macro_use]
extern crate pretty_assertions;
#[macro_use]
extern crate indoc;
#![cfg(test)]
extern crate bumpalo;
extern crate inkwell;
extern crate libc;
extern crate roc_gen;
use crate::assert_evals_to;
use crate::assert_llvm_evals_to;
use indoc::indoc;
use roc_std::RocStr;
#[macro_use]
mod helpers;
#[cfg(test)]
mod gen_dict {
use roc_std::RocStr;
#[test]
fn dict_empty_len() {
#[test]
fn dict_empty_len() {
assert_evals_to!(
indoc!(
r#"
@ -26,10 +16,10 @@ mod gen_dict {
0,
usize
);
}
}
#[test]
fn dict_insert_empty() {
#[test]
fn dict_insert_empty() {
assert_evals_to!(
indoc!(
r#"
@ -40,10 +30,10 @@ mod gen_dict {
1,
usize
);
}
}
#[test]
fn dict_empty_contains() {
#[test]
fn dict_empty_contains() {
assert_evals_to!(
indoc!(
r#"
@ -56,10 +46,10 @@ mod gen_dict {
false,
bool
);
}
}
#[test]
fn dict_nonempty_contains() {
#[test]
fn dict_nonempty_contains() {
assert_evals_to!(
indoc!(
r#"
@ -72,10 +62,10 @@ mod gen_dict {
true,
bool
);
}
}
#[test]
fn dict_empty_remove() {
#[test]
fn dict_empty_remove() {
assert_evals_to!(
indoc!(
r#"
@ -90,10 +80,10 @@ mod gen_dict {
0,
i64
);
}
}
#[test]
fn dict_nonempty_remove() {
#[test]
fn dict_nonempty_remove() {
assert_evals_to!(
indoc!(
r#"
@ -108,10 +98,10 @@ mod gen_dict {
0,
i64
);
}
}
#[test]
fn dict_nonempty_get() {
#[test]
fn dict_nonempty_get() {
assert_evals_to!(
indoc!(
r#"
@ -150,10 +140,10 @@ mod gen_dict {
0.0,
f64
);
}
}
#[test]
fn keys() {
#[test]
fn keys() {
assert_evals_to!(
indoc!(
r#"
@ -171,10 +161,10 @@ mod gen_dict {
&[0, 1, 2],
&[i64]
);
}
}
#[test]
fn values() {
#[test]
fn values() {
assert_evals_to!(
indoc!(
r#"
@ -192,10 +182,10 @@ mod gen_dict {
&[100, 200, 300],
&[i64]
);
}
}
#[test]
fn from_list_with_fold() {
#[test]
fn from_list_with_fold() {
assert_evals_to!(
indoc!(
r#"
@ -234,10 +224,10 @@ mod gen_dict {
25,
i64
);
}
}
#[test]
fn small_str_keys() {
#[test]
fn small_str_keys() {
assert_evals_to!(
indoc!(
r#"
@ -255,10 +245,10 @@ mod gen_dict {
&[RocStr::from("c"), RocStr::from("a"), RocStr::from("b"),],
&[RocStr]
);
}
}
#[test]
fn big_str_keys() {
#[test]
fn big_str_keys() {
assert_evals_to!(
indoc!(
r#"
@ -280,10 +270,10 @@ mod gen_dict {
],
&[RocStr]
);
}
}
#[test]
fn big_str_values() {
#[test]
fn big_str_values() {
assert_evals_to!(
indoc!(
r#"
@ -304,10 +294,10 @@ mod gen_dict {
],
&[RocStr]
);
}
}
#[test]
fn unit_values() {
#[test]
fn unit_values() {
assert_evals_to!(
indoc!(
r#"
@ -325,10 +315,10 @@ mod gen_dict {
4,
i64
);
}
}
#[test]
fn singleton() {
#[test]
fn singleton() {
assert_evals_to!(
indoc!(
r#"
@ -342,10 +332,10 @@ mod gen_dict {
1,
i64
);
}
}
#[test]
fn union() {
#[test]
fn union() {
assert_evals_to!(
indoc!(
r#"
@ -359,10 +349,10 @@ mod gen_dict {
2,
i64
);
}
}
#[test]
fn union_prefer_first() {
#[test]
fn union_prefer_first() {
assert_evals_to!(
indoc!(
r#"
@ -376,10 +366,10 @@ mod gen_dict {
&[100],
&[i64]
);
}
}
#[test]
fn intersection() {
#[test]
fn intersection() {
assert_evals_to!(
indoc!(
r#"
@ -406,10 +396,10 @@ mod gen_dict {
2,
i64
);
}
}
#[test]
fn intersection_prefer_first() {
#[test]
fn intersection_prefer_first() {
assert_evals_to!(
indoc!(
r#"
@ -436,10 +426,10 @@ mod gen_dict {
&[4, 2],
&[i64]
);
}
}
#[test]
fn difference() {
#[test]
fn difference() {
assert_evals_to!(
indoc!(
r#"
@ -466,10 +456,10 @@ mod gen_dict {
3,
i64
);
}
}
#[test]
fn difference_prefer_first() {
#[test]
fn difference_prefer_first() {
assert_evals_to!(
indoc!(
r#"
@ -496,10 +486,10 @@ mod gen_dict {
&[5, 3, 1],
&[i64]
);
}
}
#[test]
fn walk_sum_keys() {
#[test]
fn walk_sum_keys() {
assert_evals_to!(
indoc!(
r#"
@ -518,5 +508,4 @@ mod gen_dict {
15,
i64
);
}
}

View file

@ -1,21 +1,11 @@
#[macro_use]
extern crate pretty_assertions;
#[macro_use]
extern crate indoc;
#![cfg(test)]
extern crate bumpalo;
extern crate inkwell;
extern crate libc;
extern crate roc_gen;
use crate::assert_evals_to;
use crate::assert_llvm_evals_to;
use indoc::indoc;
#[macro_use]
mod helpers;
#[cfg(test)]
mod gen_hash {
#[test]
fn basic_hash() {
#[test]
fn basic_hash() {
assert_evals_to!(
indoc!(
r#"
@ -25,35 +15,35 @@ mod gen_hash {
9718519427346233646,
u64
);
}
}
#[test]
fn hash_str_with_seed() {
#[test]
fn hash_str_with_seed() {
assert_evals_to!("Dict.hashTestOnly 1 \"a\"", 0xbed235177f41d328, u64);
assert_evals_to!("Dict.hashTestOnly 2 \"abc\"", 0xbe348debe59b27c3, u64);
}
}
#[test]
fn hash_record() {
#[test]
fn hash_record() {
assert_evals_to!("Dict.hashTestOnly 1 { x: \"a\" } ", 0xbed235177f41d328, u64);
assert_evals_to!(
"Dict.hashTestOnly 1 { x: 42, y: 3.14 } ",
5348189196103430707,
u64
);
}
}
#[test]
fn hash_result() {
#[test]
fn hash_result() {
assert_evals_to!(
"Dict.hashTestOnly 0 (List.get [ 0x1 ] 0) ",
2878521786781103245,
u64
);
}
}
#[test]
fn hash_linked_list() {
#[test]
fn hash_linked_list() {
assert_evals_to!(
indoc!(
r#"
@ -83,10 +73,10 @@ mod gen_hash {
8287696503006938486,
u64
);
}
}
#[test]
fn hash_expr() {
#[test]
fn hash_expr() {
assert_evals_to!(
indoc!(
r#"
@ -101,10 +91,10 @@ mod gen_hash {
18264046914072177411,
u64
);
}
}
#[test]
fn hash_nullable_expr() {
#[test]
fn hash_nullable_expr() {
assert_evals_to!(
indoc!(
r#"
@ -119,10 +109,10 @@ mod gen_hash {
11103255846683455235,
u64
);
}
}
#[test]
fn hash_rosetree() {
#[test]
fn hash_rosetree() {
assert_evals_to!(
indoc!(
r#"
@ -137,10 +127,10 @@ mod gen_hash {
0,
u64
);
}
}
#[test]
fn hash_list() {
#[test]
fn hash_list() {
assert_evals_to!(
indoc!(
r#"
@ -153,5 +143,4 @@ mod gen_hash {
10731521034618280801,
u64
);
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,18 +1,8 @@
#[macro_use]
extern crate pretty_assertions;
#[macro_use]
extern crate indoc;
extern crate bumpalo;
extern crate inkwell;
extern crate libc;
extern crate roc_gen;
#[macro_use]
mod helpers;
#[cfg(test)]
mod gen_num {
use crate::assert_evals_to;
use crate::assert_llvm_evals_to;
use indoc::indoc;
use roc_std::RocOrder;
#[test]

View file

@ -1,20 +1,11 @@
#[macro_use]
extern crate pretty_assertions;
#[macro_use]
extern crate indoc;
#![cfg(test)]
extern crate bumpalo;
extern crate inkwell;
extern crate libc;
extern crate roc_gen;
use crate::assert_evals_to;
use crate::assert_llvm_evals_to;
use indoc::indoc;
#[macro_use]
mod helpers;
#[cfg(test)]
mod gen_records {
#[test]
fn basic_record() {
#[test]
fn basic_record() {
assert_evals_to!(
indoc!(
r#"
@ -44,10 +35,10 @@ mod gen_records {
19,
i64
);
}
}
#[test]
fn f64_record() {
#[test]
fn f64_record() {
assert_evals_to!(
indoc!(
r#"
@ -83,10 +74,10 @@ mod gen_records {
19.3,
f64
);
}
}
#[test]
fn fn_record() {
#[test]
fn fn_record() {
assert_evals_to!(
indoc!(
r#"
@ -134,10 +125,10 @@ mod gen_records {
34,
i64
);
}
}
#[test]
fn def_record() {
#[test]
fn def_record() {
assert_evals_to!(
indoc!(
r#"
@ -173,10 +164,10 @@ mod gen_records {
19,
i64
);
}
}
#[test]
fn when_on_record() {
#[test]
fn when_on_record() {
assert_evals_to!(
indoc!(
r#"
@ -187,10 +178,10 @@ mod gen_records {
5,
i64
);
}
}
#[test]
fn when_record_with_guard_pattern() {
#[test]
fn when_record_with_guard_pattern() {
assert_evals_to!(
indoc!(
r#"
@ -201,10 +192,10 @@ mod gen_records {
5,
i64
);
}
}
#[test]
fn let_with_record_pattern() {
#[test]
fn let_with_record_pattern() {
assert_evals_to!(
indoc!(
r#"
@ -216,10 +207,10 @@ mod gen_records {
2,
i64
);
}
}
#[test]
fn record_guard_pattern() {
#[test]
fn record_guard_pattern() {
assert_evals_to!(
indoc!(
r#"
@ -231,10 +222,10 @@ mod gen_records {
5,
i64
);
}
}
#[test]
fn twice_record_access() {
#[test]
fn twice_record_access() {
assert_evals_to!(
indoc!(
r#"
@ -246,9 +237,9 @@ mod gen_records {
5,
i64
);
}
#[test]
fn empty_record() {
}
#[test]
fn empty_record() {
assert_evals_to!(
indoc!(
r#"
@ -260,9 +251,9 @@ mod gen_records {
(),
()
);
}
#[test]
fn i64_record2_literal() {
}
#[test]
fn i64_record2_literal() {
assert_evals_to!(
indoc!(
r#"
@ -272,23 +263,23 @@ mod gen_records {
(3, 5),
(i64, i64)
);
}
}
// #[test]
// fn i64_record3_literal() {
// assert_evals_to!(
// indoc!(
// r#"
// { x: 3, y: 5, z: 17 }
// "#
// ),
// (3, 5, 17),
// (i64, i64, i64)
// );
// }
// #[test]
// fn i64_record3_literal() {
// assert_evals_to!(
// indoc!(
// r#"
// { x: 3, y: 5, z: 17 }
// "#
// ),
// (3, 5, 17),
// (i64, i64, i64)
// );
// }
#[test]
fn f64_record2_literal() {
#[test]
fn f64_record2_literal() {
assert_evals_to!(
indoc!(
r#"
@ -298,39 +289,39 @@ mod gen_records {
(3.1, 5.1),
(f64, f64)
);
}
}
// #[test]
// fn f64_record3_literal() {
// assert_evals_to!(
// indoc!(
// r#"
// { x: 3.1, y: 5.1, z: 17.1 }
// "#
// ),
// (3.1, 5.1, 17.1),
// (f64, f64, f64)
// );
// }
// #[test]
// fn f64_record3_literal() {
// assert_evals_to!(
// indoc!(
// r#"
// { x: 3.1, y: 5.1, z: 17.1 }
// "#
// ),
// (3.1, 5.1, 17.1),
// (f64, f64, f64)
// );
// }
// #[test]
// fn bool_record4_literal() {
// assert_evals_to!(
// indoc!(
// r#"
// record : { a : Bool, b : Bool, c : Bool, d : Bool }
// record = { a: True, b: True, c : True, d : Bool }
// #[test]
// fn bool_record4_literal() {
// assert_evals_to!(
// indoc!(
// r#"
// record : { a : Bool, b : Bool, c : Bool, d : Bool }
// record = { a: True, b: True, c : True, d : Bool }
// record
// "#
// ),
// (true, false, false, true),
// (bool, bool, bool, bool)
// );
// }
// record
// "#
// ),
// (true, false, false, true),
// (bool, bool, bool, bool)
// );
// }
#[test]
fn i64_record1_literal() {
#[test]
fn i64_record1_literal() {
assert_evals_to!(
indoc!(
r#"
@ -340,36 +331,36 @@ mod gen_records {
3,
i64
);
}
}
// #[test]
// fn i64_record9_literal() {
// assert_evals_to!(
// indoc!(
// r#"
// { a: 3, b: 5, c: 17, d: 1, e: 9, f: 12, g: 13, h: 14, i: 15 }
// "#
// ),
// (3, 5, 17, 1, 9, 12, 13, 14, 15),
// (i64, i64, i64, i64, i64, i64, i64, i64, i64)
// );
// }
// #[test]
// fn i64_record9_literal() {
// assert_evals_to!(
// indoc!(
// r#"
// { a: 3, b: 5, c: 17, d: 1, e: 9, f: 12, g: 13, h: 14, i: 15 }
// "#
// ),
// (3, 5, 17, 1, 9, 12, 13, 14, 15),
// (i64, i64, i64, i64, i64, i64, i64, i64, i64)
// );
// }
// #[test]
// fn f64_record3_literal() {
// assert_evals_to!(
// indoc!(
// r#"
// { x: 3.1, y: 5.1, z: 17.1 }
// "#
// ),
// (3.1, 5.1, 17.1),
// (f64, f64, f64)
// );
// }
// #[test]
// fn f64_record3_literal() {
// assert_evals_to!(
// indoc!(
// r#"
// { x: 3.1, y: 5.1, z: 17.1 }
// "#
// ),
// (3.1, 5.1, 17.1),
// (f64, f64, f64)
// );
// }
#[test]
fn bool_literal() {
#[test]
fn bool_literal() {
assert_evals_to!(
indoc!(
r#"
@ -382,10 +373,10 @@ mod gen_records {
true,
bool
);
}
}
#[test]
fn return_record() {
#[test]
fn return_record() {
assert_evals_to!(
indoc!(
r#"
@ -398,10 +389,10 @@ mod gen_records {
(4, 3),
(i64, i64)
);
}
}
#[test]
fn optional_field_when_use_default() {
#[test]
fn optional_field_when_use_default() {
assert_evals_to!(
indoc!(
r#"
@ -425,10 +416,10 @@ mod gen_records {
3 * 5 * 7 * 11,
i64
);
}
}
#[test]
fn optional_field_when_use_default_nested() {
#[test]
fn optional_field_when_use_default_nested() {
assert_evals_to!(
indoc!(
r#"
@ -448,10 +439,10 @@ mod gen_records {
3 * 5 * 7 * 11,
i64
);
}
}
#[test]
fn optional_field_when_no_use_default() {
#[test]
fn optional_field_when_no_use_default() {
assert_evals_to!(
indoc!(
r#"
@ -468,10 +459,10 @@ mod gen_records {
13,
i64
);
}
}
#[test]
fn optional_field_when_no_use_default_nested() {
#[test]
fn optional_field_when_no_use_default_nested() {
assert_evals_to!(
indoc!(
r#"
@ -485,10 +476,10 @@ mod gen_records {
13,
i64
);
}
}
#[test]
fn optional_field_let_use_default() {
#[test]
fn optional_field_let_use_default() {
assert_evals_to!(
indoc!(
r#"
@ -505,10 +496,10 @@ mod gen_records {
19,
i64
);
}
}
#[test]
fn optional_field_let_no_use_default() {
#[test]
fn optional_field_let_no_use_default() {
assert_evals_to!(
indoc!(
r#"
@ -525,10 +516,10 @@ mod gen_records {
13,
i64
);
}
}
#[test]
fn optional_field_let_no_use_default_nested() {
#[test]
fn optional_field_let_no_use_default_nested() {
assert_evals_to!(
indoc!(
r#"
@ -542,10 +533,10 @@ mod gen_records {
13,
i64
);
}
}
#[test]
fn optional_field_function_use_default() {
#[test]
fn optional_field_function_use_default() {
assert_evals_to!(
indoc!(
r#"
@ -558,11 +549,11 @@ mod gen_records {
19,
i64
);
}
}
#[test]
#[ignore]
fn optional_field_function_no_use_default() {
#[test]
#[ignore]
fn optional_field_function_no_use_default() {
// blocked on https://github.com/rtfeldman/roc/issues/786
assert_evals_to!(
indoc!(
@ -578,11 +569,11 @@ mod gen_records {
13,
i64
);
}
}
#[test]
#[ignore]
fn optional_field_function_no_use_default_nested() {
#[test]
#[ignore]
fn optional_field_function_no_use_default_nested() {
// blocked on https://github.com/rtfeldman/roc/issues/786
assert_evals_to!(
indoc!(
@ -596,10 +587,10 @@ mod gen_records {
13,
i64
);
}
}
#[test]
fn optional_field_singleton_record() {
#[test]
fn optional_field_singleton_record() {
assert_evals_to!(
indoc!(
r#"
@ -610,10 +601,10 @@ mod gen_records {
4,
i64
);
}
}
#[test]
fn optional_field_empty_record() {
#[test]
fn optional_field_empty_record() {
assert_evals_to!(
indoc!(
r#"
@ -624,10 +615,10 @@ mod gen_records {
3,
i64
);
}
}
#[test]
fn return_record_2() {
#[test]
fn return_record_2() {
assert_evals_to!(
indoc!(
r#"
@ -637,10 +628,10 @@ mod gen_records {
[3, 5],
[i64; 2]
);
}
}
#[test]
fn return_record_3() {
#[test]
fn return_record_3() {
assert_evals_to!(
indoc!(
r#"
@ -650,10 +641,10 @@ mod gen_records {
(3, 5, 4),
(i64, i64, i64)
);
}
}
#[test]
fn return_record_4() {
#[test]
fn return_record_4() {
assert_evals_to!(
indoc!(
r#"
@ -663,10 +654,10 @@ mod gen_records {
[3, 5, 4, 2],
[i64; 4]
);
}
}
#[test]
fn return_record_5() {
#[test]
fn return_record_5() {
assert_evals_to!(
indoc!(
r#"
@ -676,10 +667,10 @@ mod gen_records {
[3, 5, 4, 2, 1],
[i64; 5]
);
}
}
#[test]
fn return_record_6() {
#[test]
fn return_record_6() {
assert_evals_to!(
indoc!(
r#"
@ -689,10 +680,10 @@ mod gen_records {
[3, 5, 4, 2, 1, 7],
[i64; 6]
);
}
}
#[test]
fn return_record_7() {
#[test]
fn return_record_7() {
assert_evals_to!(
indoc!(
r#"
@ -702,10 +693,10 @@ mod gen_records {
[3, 5, 4, 2, 1, 7, 8],
[i64; 7]
);
}
}
#[test]
fn return_record_float_int() {
#[test]
fn return_record_float_int() {
assert_evals_to!(
indoc!(
r#"
@ -715,10 +706,10 @@ mod gen_records {
(3.14, 0x1),
(f64, i64)
);
}
}
#[test]
fn return_record_int_float() {
#[test]
fn return_record_int_float() {
assert_evals_to!(
indoc!(
r#"
@ -728,10 +719,10 @@ mod gen_records {
(0x1, 3.14),
(i64, f64)
);
}
}
#[test]
fn return_record_float_float() {
#[test]
fn return_record_float_float() {
assert_evals_to!(
indoc!(
r#"
@ -741,10 +732,10 @@ mod gen_records {
(6.28, 3.14),
(f64, f64)
);
}
}
#[test]
fn return_record_float_float_float() {
#[test]
fn return_record_float_float_float() {
assert_evals_to!(
indoc!(
r#"
@ -754,10 +745,10 @@ mod gen_records {
(6.28, 3.14, 0.1),
(f64, f64, f64)
);
}
}
#[test]
fn return_nested_record() {
#[test]
fn return_nested_record() {
assert_evals_to!(
indoc!(
r#"
@ -767,10 +758,10 @@ mod gen_records {
(0x0, (6.28, 3.14, 0.1)),
(i64, (f64, f64, f64))
);
}
}
#[test]
fn accessor() {
#[test]
fn accessor() {
assert_evals_to!(
indoc!(
r#"
@ -780,10 +771,10 @@ mod gen_records {
7,
i64
);
}
}
#[test]
fn accessor_single_element_record() {
#[test]
fn accessor_single_element_record() {
assert_evals_to!(
indoc!(
r#"
@ -793,10 +784,10 @@ mod gen_records {
4,
i64
);
}
}
#[test]
fn update_record() {
#[test]
fn update_record() {
assert_evals_to!(
indoc!(
r#"
@ -808,10 +799,10 @@ mod gen_records {
(6.28, 43),
(f64, i64)
);
}
}
#[test]
fn update_single_element_record() {
#[test]
fn update_single_element_record() {
assert_evals_to!(
indoc!(
r#"
@ -823,10 +814,10 @@ mod gen_records {
43,
i64
);
}
}
#[test]
fn booleans_in_record() {
#[test]
fn booleans_in_record() {
assert_evals_to!(
indoc!("{ x: 1 == 1, y: 1 == 1 }"),
(true, true),
@ -847,19 +838,19 @@ mod gen_records {
(false, false),
(bool, bool)
);
}
}
#[test]
fn alignment_in_record() {
#[test]
fn alignment_in_record() {
assert_evals_to!(
indoc!("{ c: 32, b: if True then Red else if True then Green else Blue, a: 1 == 1 }"),
(32i64, true, 2u8),
(i64, bool, u8)
);
}
}
#[test]
fn blue_and_present() {
#[test]
fn blue_and_present() {
assert_evals_to!(
indoc!(
r#"
@ -874,10 +865,10 @@ mod gen_records {
7,
i64
);
}
}
#[test]
fn blue_and_absent() {
#[test]
fn blue_and_absent() {
assert_evals_to!(
indoc!(
r#"
@ -892,5 +883,4 @@ mod gen_records {
3,
i64
);
}
}

View file

@ -1,21 +1,11 @@
#[macro_use]
extern crate pretty_assertions;
#[macro_use]
extern crate indoc;
#![cfg(test)]
extern crate bumpalo;
extern crate inkwell;
extern crate libc;
extern crate roc_gen;
use crate::assert_evals_to;
use crate::assert_llvm_evals_to;
use indoc::indoc;
#[macro_use]
mod helpers;
#[cfg(test)]
mod gen_result {
#[test]
fn with_default() {
#[test]
fn with_default() {
assert_evals_to!(
indoc!(
r#"
@ -41,10 +31,10 @@ mod gen_result {
0,
i64
);
}
}
#[test]
fn result_map() {
#[test]
fn result_map() {
assert_evals_to!(
indoc!(
r#"
@ -74,10 +64,10 @@ mod gen_result {
0,
i64
);
}
}
#[test]
fn result_map_err() {
#[test]
fn result_map_err() {
assert_evals_to!(
indoc!(
r#"
@ -107,5 +97,4 @@ mod gen_result {
0,
i64
);
}
}

View file

@ -1,21 +1,11 @@
#[macro_use]
extern crate pretty_assertions;
#[macro_use]
extern crate indoc;
#![cfg(test)]
extern crate bumpalo;
extern crate inkwell;
extern crate libc;
extern crate roc_gen;
use crate::assert_evals_to;
use crate::assert_llvm_evals_to;
use indoc::indoc;
#[macro_use]
mod helpers;
#[cfg(test)]
mod gen_set {
#[test]
fn empty_len() {
#[test]
fn empty_len() {
assert_evals_to!(
indoc!(
r#"
@ -25,10 +15,10 @@ mod gen_set {
0,
usize
);
}
}
#[test]
fn singleton_len() {
#[test]
fn singleton_len() {
assert_evals_to!(
indoc!(
r#"
@ -38,10 +28,10 @@ mod gen_set {
1,
usize
);
}
}
#[test]
fn singleton_to_list() {
#[test]
fn singleton_to_list() {
assert_evals_to!(
indoc!(
r#"
@ -71,10 +61,10 @@ mod gen_set {
&[1.0],
&[f64]
);
}
}
#[test]
fn insert() {
#[test]
fn insert() {
assert_evals_to!(
indoc!(
r#"
@ -88,10 +78,10 @@ mod gen_set {
&[0, 1, 2],
&[i64]
);
}
}
#[test]
fn remove() {
#[test]
fn remove() {
assert_evals_to!(
indoc!(
r#"
@ -106,10 +96,10 @@ mod gen_set {
&[0],
&[i64]
);
}
}
#[test]
fn union() {
#[test]
fn union() {
assert_evals_to!(
indoc!(
r#"
@ -126,10 +116,10 @@ mod gen_set {
&[4, 2, 3, 1],
&[i64]
);
}
}
#[test]
fn difference() {
#[test]
fn difference() {
assert_evals_to!(
indoc!(
r#"
@ -146,10 +136,10 @@ mod gen_set {
&[2],
&[i64]
);
}
}
#[test]
fn intersection() {
#[test]
fn intersection() {
assert_evals_to!(
indoc!(
r#"
@ -166,10 +156,10 @@ mod gen_set {
&[1],
&[i64]
);
}
}
#[test]
fn walk_sum() {
#[test]
fn walk_sum() {
assert_evals_to!(
indoc!(
r#"
@ -179,10 +169,10 @@ mod gen_set {
6,
i64
);
}
}
#[test]
fn contains() {
#[test]
fn contains() {
assert_evals_to!(
indoc!(
r#"
@ -202,10 +192,10 @@ mod gen_set {
false,
bool
);
}
}
#[test]
fn from_list() {
#[test]
fn from_list() {
assert_evals_to!(
indoc!(
r#"
@ -244,5 +234,4 @@ mod gen_set {
&[],
&[i64]
);
}
}

View file

@ -1,27 +1,14 @@
#[macro_use]
extern crate pretty_assertions;
#[macro_use]
extern crate indoc;
extern crate bumpalo;
extern crate inkwell;
extern crate libc;
extern crate roc_gen;
#![cfg(test)]
use crate::assert_evals_to;
use crate::assert_llvm_evals_to;
use indoc::indoc;
use roc_std::RocStr;
#[macro_use]
mod helpers;
use std::cmp::min;
const ROC_STR_MEM_SIZE: usize = core::mem::size_of::<RocStr>();
#[cfg(test)]
mod gen_str {
use crate::ROC_STR_MEM_SIZE;
use roc_std::RocStr;
use std::cmp::min;
fn small_str(str: &str) -> [u8; ROC_STR_MEM_SIZE] {
fn small_str(str: &str) -> [u8; ROC_STR_MEM_SIZE] {
let mut bytes: [u8; ROC_STR_MEM_SIZE] = Default::default();
let mut index: usize = 0;
@ -42,10 +29,10 @@ mod gen_str {
bytes[ROC_STR_MEM_SIZE - 1] = 0b1000_0000 ^ (output_len as u8);
bytes
}
}
#[test]
fn str_split_bigger_delimiter_small_str() {
#[test]
fn str_split_bigger_delimiter_small_str() {
assert_evals_to!(
indoc!(
r#"
@ -71,10 +58,10 @@ mod gen_str {
3,
i64
);
}
}
#[test]
fn str_split_str_concat_repeated() {
#[test]
fn str_split_str_concat_repeated() {
assert_evals_to!(
indoc!(
r#"
@ -94,10 +81,10 @@ mod gen_str {
"JJJJJJJJJJJJJJJJJJJJJJJJJ",
&'static str
);
}
}
#[test]
fn str_split_small_str_bigger_delimiter() {
#[test]
fn str_split_small_str_bigger_delimiter() {
assert_evals_to!(
indoc!(
r#"
@ -112,10 +99,10 @@ mod gen_str {
small_str("JJJ"),
[u8; ROC_STR_MEM_SIZE]
);
}
}
#[test]
fn str_split_big_str_small_delimiter() {
#[test]
fn str_split_big_str_small_delimiter() {
assert_evals_to!(
indoc!(
r#"
@ -135,10 +122,10 @@ mod gen_str {
&["01234567789abcdefghi ", " 01234567789abcdefghi"],
&'static [&'static str]
);
}
}
#[test]
fn str_split_small_str_small_delimiter() {
#[test]
fn str_split_small_str_small_delimiter() {
assert_evals_to!(
indoc!(
r#"
@ -148,10 +135,10 @@ mod gen_str {
&[small_str("J"), small_str("J"), small_str("J")],
&'static [[u8; ROC_STR_MEM_SIZE]]
);
}
}
#[test]
fn str_split_bigger_delimiter_big_strs() {
#[test]
fn str_split_bigger_delimiter_big_strs() {
assert_evals_to!(
indoc!(
r#"
@ -163,10 +150,10 @@ mod gen_str {
&["string to split is shorter"],
&'static [&'static str]
);
}
}
#[test]
fn str_split_empty_strs() {
#[test]
fn str_split_empty_strs() {
assert_evals_to!(
indoc!(
r#"
@ -176,10 +163,10 @@ mod gen_str {
&[small_str("")],
&'static [[u8; ROC_STR_MEM_SIZE]]
)
}
}
#[test]
fn str_split_minimal_example() {
#[test]
fn str_split_minimal_example() {
assert_evals_to!(
indoc!(
r#"
@ -189,10 +176,10 @@ mod gen_str {
&[small_str("a"), small_str("")],
&'static [[u8; ROC_STR_MEM_SIZE]]
)
}
}
#[test]
fn str_split_small_str_big_delimiter() {
#[test]
fn str_split_small_str_big_delimiter() {
assert_evals_to!(
indoc!(
r#"
@ -217,10 +204,10 @@ mod gen_str {
&[small_str("1"), small_str("2"), small_str("")],
&'static [[u8; ROC_STR_MEM_SIZE]]
);
}
}
#[test]
fn str_split_small_str_20_char_delimiter() {
#[test]
fn str_split_small_str_20_char_delimiter() {
assert_evals_to!(
indoc!(
r#"
@ -232,10 +219,10 @@ mod gen_str {
&[small_str("3"), small_str("4"), small_str("")],
&'static [[u8; ROC_STR_MEM_SIZE]]
);
}
}
#[test]
fn str_concat_big_to_big() {
#[test]
fn str_concat_big_to_big() {
assert_evals_to!(
indoc!(
r#"
@ -247,10 +234,10 @@ mod gen_str {
"First string that is fairly long. Longer strings make for different errors. Second string that is also fairly long. Two long strings test things that might not appear with short strings.",
&'static str
);
}
}
#[test]
fn small_str_literal() {
#[test]
fn small_str_literal() {
assert_evals_to!(
"\"JJJJJJJJJJJJJJJ\"",
[
@ -273,10 +260,10 @@ mod gen_str {
],
[u8; 16]
);
}
}
#[test]
fn small_str_zeroed_literal() {
#[test]
fn small_str_zeroed_literal() {
// Verifies that we zero out unused bytes in the string.
// This is important so that string equality tests don't randomly
// fail due to unused memory being there!
@ -302,10 +289,10 @@ mod gen_str {
],
[u8; 16]
);
}
}
#[test]
fn small_str_concat_empty_first_arg() {
#[test]
fn small_str_concat_empty_first_arg() {
assert_evals_to!(
r#"Str.concat "" "JJJJJJJJJJJJJJJ""#,
[
@ -328,10 +315,10 @@ mod gen_str {
],
[u8; 16]
);
}
}
#[test]
fn small_str_concat_empty_second_arg() {
#[test]
fn small_str_concat_empty_second_arg() {
assert_evals_to!(
r#"Str.concat "JJJJJJJJJJJJJJJ" """#,
[
@ -354,19 +341,19 @@ mod gen_str {
],
[u8; 16]
);
}
}
#[test]
fn small_str_concat_small_to_big() {
#[test]
fn small_str_concat_small_to_big() {
assert_evals_to!(
r#"Str.concat "abc" " this is longer than 15 chars""#,
"abc this is longer than 15 chars",
&'static str
);
}
}
#[test]
fn small_str_concat_small_to_small_staying_small() {
#[test]
fn small_str_concat_small_to_small_staying_small() {
assert_evals_to!(
r#"Str.concat "J" "JJJJJJJJJJJJJJ""#,
[
@ -389,110 +376,110 @@ mod gen_str {
],
[u8; 16]
);
}
}
#[test]
fn small_str_concat_small_to_small_overflow_to_big() {
#[test]
fn small_str_concat_small_to_small_overflow_to_big() {
assert_evals_to!(
r#"Str.concat "abcdefghijklm" "nopqrstuvwxyz""#,
"abcdefghijklmnopqrstuvwxyz",
&'static str
);
}
}
#[test]
fn str_concat_empty() {
#[test]
fn str_concat_empty() {
assert_evals_to!(r#"Str.concat "" """#, "", &'static str);
}
}
#[test]
fn small_str_is_empty() {
#[test]
fn small_str_is_empty() {
assert_evals_to!(r#"Str.isEmpty "abc""#, false, bool);
}
}
#[test]
fn big_str_is_empty() {
#[test]
fn big_str_is_empty() {
assert_evals_to!(
r#"Str.isEmpty "this is more than 15 chars long""#,
false,
bool
);
}
}
#[test]
fn empty_str_is_empty() {
#[test]
fn empty_str_is_empty() {
assert_evals_to!(r#"Str.isEmpty """#, true, bool);
}
}
#[test]
fn str_starts_with() {
#[test]
fn str_starts_with() {
assert_evals_to!(r#"Str.startsWith "hello world" "hell""#, true, bool);
assert_evals_to!(r#"Str.startsWith "hello world" """#, true, bool);
assert_evals_to!(r#"Str.startsWith "nope" "hello world""#, false, bool);
assert_evals_to!(r#"Str.startsWith "hell" "hello world""#, false, bool);
assert_evals_to!(r#"Str.startsWith "" "hello world""#, false, bool);
}
}
#[test]
fn str_ends_with() {
#[test]
fn str_ends_with() {
assert_evals_to!(r#"Str.endsWith "hello world" "world""#, true, bool);
assert_evals_to!(r#"Str.endsWith "nope" "hello world""#, false, bool);
assert_evals_to!(r#"Str.endsWith "" "hello world""#, false, bool);
}
}
#[test]
fn str_count_graphemes_small_str() {
#[test]
fn str_count_graphemes_small_str() {
assert_evals_to!(r#"Str.countGraphemes "å🤔""#, 2, usize);
}
}
#[test]
fn str_count_graphemes_three_js() {
#[test]
fn str_count_graphemes_three_js() {
assert_evals_to!(r#"Str.countGraphemes "JJJ""#, 3, usize);
}
}
#[test]
fn str_count_graphemes_big_str() {
#[test]
fn str_count_graphemes_big_str() {
assert_evals_to!(
r#"Str.countGraphemes "6🤔å🤔e¥🤔çppkd🙃1jdal🦯asdfa∆ltråø˚waia8918.,🏅jjc""#,
45,
usize
);
}
}
#[test]
fn str_starts_with_same_big_str() {
#[test]
fn str_starts_with_same_big_str() {
assert_evals_to!(
r#"Str.startsWith "123456789123456789" "123456789123456789""#,
true,
bool
);
}
}
#[test]
fn str_starts_with_different_big_str() {
#[test]
fn str_starts_with_different_big_str() {
assert_evals_to!(
r#"Str.startsWith "12345678912345678910" "123456789123456789""#,
true,
bool
);
}
}
#[test]
fn str_starts_with_same_small_str() {
#[test]
fn str_starts_with_same_small_str() {
assert_evals_to!(r#"Str.startsWith "1234" "1234""#, true, bool);
}
}
#[test]
fn str_starts_with_different_small_str() {
#[test]
fn str_starts_with_different_small_str() {
assert_evals_to!(r#"Str.startsWith "1234" "12""#, true, bool);
}
#[test]
fn str_starts_with_false_small_str() {
}
#[test]
fn str_starts_with_false_small_str() {
assert_evals_to!(r#"Str.startsWith "1234" "23""#, false, bool);
}
}
#[test]
fn str_from_int() {
#[test]
fn str_from_int() {
assert_evals_to!(
r#"Str.fromInt 1234"#,
roc_std::RocStr::from_slice("1234".as_bytes()),
@ -514,10 +501,10 @@ mod gen_str {
let min = format!("{}", i64::MIN);
assert_evals_to!(r#"Str.fromInt Num.minInt"#, &min, &'static str);
}
}
#[test]
fn str_from_utf8_pass_single_ascii() {
#[test]
fn str_from_utf8_pass_single_ascii() {
assert_evals_to!(
indoc!(
r#"
@ -529,10 +516,10 @@ mod gen_str {
roc_std::RocStr::from_slice("a".as_bytes()),
roc_std::RocStr
);
}
}
#[test]
fn str_from_utf8_pass_many_ascii() {
#[test]
fn str_from_utf8_pass_many_ascii() {
assert_evals_to!(
indoc!(
r#"
@ -544,10 +531,10 @@ mod gen_str {
roc_std::RocStr::from_slice("abc~".as_bytes()),
roc_std::RocStr
);
}
}
#[test]
fn str_from_utf8_pass_single_unicode() {
#[test]
fn str_from_utf8_pass_single_unicode() {
assert_evals_to!(
indoc!(
r#"
@ -559,10 +546,10 @@ mod gen_str {
roc_std::RocStr::from_slice("".as_bytes()),
roc_std::RocStr
);
}
}
#[test]
fn str_from_utf8_pass_many_unicode() {
#[test]
fn str_from_utf8_pass_many_unicode() {
assert_evals_to!(
indoc!(
r#"
@ -574,10 +561,10 @@ mod gen_str {
roc_std::RocStr::from_slice("∆œ¬".as_bytes()),
roc_std::RocStr
);
}
}
#[test]
fn str_from_utf8_pass_single_grapheme() {
#[test]
fn str_from_utf8_pass_single_grapheme() {
assert_evals_to!(
indoc!(
r#"
@ -589,10 +576,10 @@ mod gen_str {
roc_std::RocStr::from_slice("💖".as_bytes()),
roc_std::RocStr
);
}
}
#[test]
fn str_from_utf8_pass_many_grapheme() {
#[test]
fn str_from_utf8_pass_many_grapheme() {
assert_evals_to!(
indoc!(
r#"
@ -604,10 +591,10 @@ mod gen_str {
roc_std::RocStr::from_slice("💖🤠🚀".as_bytes()),
roc_std::RocStr
);
}
}
#[test]
fn str_from_utf8_pass_all() {
#[test]
fn str_from_utf8_pass_all() {
assert_evals_to!(
indoc!(
r#"
@ -619,10 +606,10 @@ mod gen_str {
roc_std::RocStr::from_slice("💖b∆".as_bytes()),
roc_std::RocStr
);
}
}
#[test]
fn str_from_utf8_fail_invalid_start_byte() {
#[test]
fn str_from_utf8_fail_invalid_start_byte() {
assert_evals_to!(
indoc!(
r#"
@ -638,10 +625,10 @@ mod gen_str {
roc_std::RocStr::from_slice("a".as_bytes()),
roc_std::RocStr
);
}
}
#[test]
fn str_from_utf8_fail_unexpected_end_of_sequence() {
#[test]
fn str_from_utf8_fail_unexpected_end_of_sequence() {
assert_evals_to!(
indoc!(
r#"
@ -657,10 +644,10 @@ mod gen_str {
roc_std::RocStr::from_slice("a".as_bytes()),
roc_std::RocStr
);
}
}
#[test]
fn str_from_utf8_fail_expected_continuation() {
#[test]
fn str_from_utf8_fail_expected_continuation() {
assert_evals_to!(
indoc!(
r#"
@ -676,10 +663,10 @@ mod gen_str {
roc_std::RocStr::from_slice("a".as_bytes()),
roc_std::RocStr
);
}
}
#[test]
fn str_from_utf8_fail_overlong_encoding() {
#[test]
fn str_from_utf8_fail_overlong_encoding() {
assert_evals_to!(
indoc!(
r#"
@ -695,10 +682,10 @@ mod gen_str {
roc_std::RocStr::from_slice("a".as_bytes()),
roc_std::RocStr
);
}
}
#[test]
fn str_from_utf8_fail_codepoint_too_large() {
#[test]
fn str_from_utf8_fail_codepoint_too_large() {
assert_evals_to!(
indoc!(
r#"
@ -714,10 +701,10 @@ mod gen_str {
roc_std::RocStr::from_slice("a".as_bytes()),
roc_std::RocStr
);
}
}
#[test]
fn str_from_utf8_fail_surrogate_half() {
#[test]
fn str_from_utf8_fail_surrogate_half() {
assert_evals_to!(
indoc!(
r#"
@ -733,10 +720,10 @@ mod gen_str {
roc_std::RocStr::from_slice("a".as_bytes()),
roc_std::RocStr
);
}
}
#[test]
fn str_equality() {
#[test]
fn str_equality() {
assert_evals_to!(r#""a" == "a""#, true, bool);
assert_evals_to!(
r#""loremipsumdolarsitamet" == "loremipsumdolarsitamet""#,
@ -745,10 +732,10 @@ mod gen_str {
);
assert_evals_to!(r#""a" != "b""#, true, bool);
assert_evals_to!(r#""a" == "b""#, false, bool);
}
}
#[test]
fn str_clone() {
#[test]
fn str_clone() {
use roc_std::RocStr;
let long = RocStr::from_slice("loremipsumdolarsitamet".as_bytes());
let short = RocStr::from_slice("x".as_bytes());
@ -757,10 +744,10 @@ mod gen_str {
debug_assert_eq!(long.clone(), long);
debug_assert_eq!(short.clone(), short);
debug_assert_eq!(empty.clone(), empty);
}
}
#[test]
fn nested_recursive_literal() {
#[test]
fn nested_recursive_literal() {
assert_evals_to!(
indoc!(
r#"
@ -787,46 +774,45 @@ mod gen_str {
"Add (Add (Val 3) (Val 1)) (Add (Val 1) (Var 1))",
&'static str
);
}
}
#[test]
fn str_join_comma_small() {
#[test]
fn str_join_comma_small() {
assert_evals_to!(
r#"Str.joinWith ["1", "2"] ", " "#,
RocStr::from("1, 2"),
RocStr
);
}
}
#[test]
fn str_join_comma_big() {
#[test]
fn str_join_comma_big() {
assert_evals_to!(
r#"Str.joinWith ["10000000", "2000000", "30000000"] ", " "#,
RocStr::from("10000000, 2000000, 30000000"),
RocStr
);
}
}
#[test]
fn str_join_comma_single() {
#[test]
fn str_join_comma_single() {
assert_evals_to!(r#"Str.joinWith ["1"] ", " "#, RocStr::from("1"), RocStr);
}
}
#[test]
fn str_from_float() {
#[test]
fn str_from_float() {
assert_evals_to!(r#"Str.fromFloat 3.14"#, RocStr::from("3.140000"), RocStr);
}
}
#[test]
fn str_to_bytes() {
#[test]
fn str_to_bytes() {
assert_evals_to!(r#"Str.toBytes "hello""#, &[104, 101, 108, 108, 111], &[u8]);
assert_evals_to!(
r#"Str.toBytes "this is a long string""#,
&[
116, 104, 105, 115, 32, 105, 115, 32, 97, 32, 108, 111, 110, 103, 32, 115, 116,
114, 105, 110, 103
116, 104, 105, 115, 32, 105, 115, 32, 97, 32, 108, 111, 110, 103, 32, 115, 116, 114,
105, 110, 103
],
&[u8]
);
}
}

View file

@ -1,17 +1,11 @@
extern crate bumpalo;
extern crate inkwell;
extern crate libc;
extern crate roc_gen;
#![cfg(test)]
#[cfg(test)]
mod gen_tags {
#[macro_use]
use crate::assert_evals_to;
use crate::assert_llvm_evals_to;
use indoc::indoc;
use crate::assert_evals_to;
use crate::assert_llvm_evals_to;
use indoc::indoc;
#[test]
fn applied_tag_nothing_ir() {
#[test]
fn applied_tag_nothing_ir() {
assert_evals_to!(
indoc!(
r#"
@ -27,10 +21,10 @@ mod gen_tags {
(i64, i64),
|(tag, _)| tag
);
}
}
#[test]
fn applied_tag_nothing() {
#[test]
fn applied_tag_nothing() {
assert_evals_to!(
indoc!(
r#"
@ -46,10 +40,10 @@ mod gen_tags {
(i64, i64),
|(tag, _)| tag
);
}
}
#[test]
fn applied_tag_just() {
#[test]
fn applied_tag_just() {
assert_evals_to!(
indoc!(
r#"
@ -64,10 +58,10 @@ mod gen_tags {
(0, 0x4),
(i64, i64)
);
}
}
#[test]
fn applied_tag_just_ir() {
#[test]
fn applied_tag_just_ir() {
assert_evals_to!(
indoc!(
r#"
@ -82,10 +76,10 @@ mod gen_tags {
(0, 0x4),
(i64, i64)
);
}
}
#[test]
fn applied_tag_just_enum() {
#[test]
fn applied_tag_just_enum() {
assert_evals_to!(
indoc!(
r#"
@ -104,26 +98,26 @@ mod gen_tags {
(0, 2),
(i64, u8)
);
}
}
// #[test]
// fn raw_result() {
// assert_evals_to!(
// indoc!(
// r#"
// x : Result I64 I64
// x = Err 41
// #[test]
// fn raw_result() {
// assert_evals_to!(
// indoc!(
// r#"
// x : Result I64 I64
// x = Err 41
// x
// "#
// ),
// 0,
// i8
// );
// }
// x
// "#
// ),
// 0,
// i8
// );
// }
#[test]
fn true_is_true() {
#[test]
fn true_is_true() {
assert_evals_to!(
indoc!(
r#"
@ -136,10 +130,10 @@ mod gen_tags {
true,
bool
);
}
}
#[test]
fn false_is_false() {
#[test]
fn false_is_false() {
assert_evals_to!(
indoc!(
r#"
@ -152,10 +146,10 @@ mod gen_tags {
false,
bool
);
}
}
#[test]
fn basic_enum() {
#[test]
fn basic_enum() {
assert_evals_to!(
indoc!(
r#"
@ -173,67 +167,67 @@ mod gen_tags {
false,
bool
);
}
}
// #[test]
// fn linked_list_empty() {
// assert_evals_to!(
// indoc!(
// r#"
// LinkedList a : [ Cons a (LinkedList a), Nil ]
//
// empty : LinkedList I64
// empty = Nil
//
// 1
// "#
// ),
// 1,
// i64
// );
// }
//
// #[test]
// fn linked_list_singleton() {
// assert_evals_to!(
// indoc!(
// r#"
// LinkedList a : [ Cons a (LinkedList a), Nil ]
//
// singleton : LinkedList I64
// singleton = Cons 0x1 Nil
//
// 1
// "#
// ),
// 1,
// i64
// );
// }
//
// #[test]
// fn linked_list_is_empty() {
// assert_evals_to!(
// indoc!(
// r#"
// LinkedList a : [ Cons a (LinkedList a), Nil ]
//
// isEmpty : LinkedList a -> Bool
// isEmpty = \list ->
// when list is
// Nil -> True
// Cons _ _ -> False
//
// isEmpty (Cons 4 Nil)
// "#
// ),
// false,
// bool
// );
// }
// #[test]
// fn linked_list_empty() {
// assert_evals_to!(
// indoc!(
// r#"
// LinkedList a : [ Cons a (LinkedList a), Nil ]
//
// empty : LinkedList I64
// empty = Nil
//
// 1
// "#
// ),
// 1,
// i64
// );
// }
//
// #[test]
// fn linked_list_singleton() {
// assert_evals_to!(
// indoc!(
// r#"
// LinkedList a : [ Cons a (LinkedList a), Nil ]
//
// singleton : LinkedList I64
// singleton = Cons 0x1 Nil
//
// 1
// "#
// ),
// 1,
// i64
// );
// }
//
// #[test]
// fn linked_list_is_empty() {
// assert_evals_to!(
// indoc!(
// r#"
// LinkedList a : [ Cons a (LinkedList a), Nil ]
//
// isEmpty : LinkedList a -> Bool
// isEmpty = \list ->
// when list is
// Nil -> True
// Cons _ _ -> False
//
// isEmpty (Cons 4 Nil)
// "#
// ),
// false,
// bool
// );
// }
#[test]
fn even_odd() {
#[test]
fn even_odd() {
assert_evals_to!(
indoc!(
r#"
@ -255,10 +249,10 @@ mod gen_tags {
true,
bool
);
}
}
#[test]
fn gen_literal_true() {
#[test]
fn gen_literal_true() {
assert_evals_to!(
indoc!(
r#"
@ -268,10 +262,10 @@ mod gen_tags {
-1,
i64
);
}
}
#[test]
fn gen_if_float() {
#[test]
fn gen_if_float() {
assert_evals_to!(
indoc!(
r#"
@ -281,9 +275,9 @@ mod gen_tags {
-1.0,
f64
);
}
#[test]
fn when_on_nothing() {
}
#[test]
fn when_on_nothing() {
assert_evals_to!(
indoc!(
r#"
@ -298,10 +292,10 @@ mod gen_tags {
2,
i64
);
}
}
#[test]
fn when_on_just() {
#[test]
fn when_on_just() {
assert_evals_to!(
indoc!(
r#"
@ -316,10 +310,10 @@ mod gen_tags {
42,
i64
);
}
}
#[test]
fn when_on_result() {
#[test]
fn when_on_result() {
assert_evals_to!(
indoc!(
r#"
@ -334,10 +328,10 @@ mod gen_tags {
42,
i64
);
}
}
#[test]
fn when_on_these() {
#[test]
fn when_on_these() {
assert_evals_to!(
indoc!(
r#"
@ -355,10 +349,10 @@ mod gen_tags {
5,
i64
);
}
}
#[test]
fn match_on_two_values() {
#[test]
fn match_on_two_values() {
// this will produce a Chain internally
assert_evals_to!(
indoc!(
@ -371,10 +365,10 @@ mod gen_tags {
5,
i64
);
}
}
#[test]
fn pair_with_guard_pattern() {
#[test]
fn pair_with_guard_pattern() {
assert_evals_to!(
indoc!(
r#"
@ -387,10 +381,10 @@ mod gen_tags {
5,
i64
);
}
}
#[test]
fn result_with_guard_pattern() {
#[test]
fn result_with_guard_pattern() {
// This test revealed an issue with hashing Test values
assert_evals_to!(
indoc!(
@ -407,10 +401,10 @@ mod gen_tags {
2,
i64
);
}
}
#[test]
fn maybe_is_just() {
#[test]
fn maybe_is_just() {
assert_evals_to!(
indoc!(
r#"
@ -431,10 +425,10 @@ mod gen_tags {
true,
bool
);
}
}
#[test]
fn maybe_is_just_nested() {
#[test]
fn maybe_is_just_nested() {
assert_evals_to!(
indoc!(
r#"
@ -452,10 +446,10 @@ mod gen_tags {
true,
bool
);
}
}
#[test]
fn nested_pattern_match() {
#[test]
fn nested_pattern_match() {
assert_evals_to!(
indoc!(
r#"
@ -472,9 +466,9 @@ mod gen_tags {
42,
i64
);
}
#[test]
fn if_guard_pattern_false() {
}
#[test]
fn if_guard_pattern_false() {
assert_evals_to!(
indoc!(
r#"
@ -489,10 +483,10 @@ mod gen_tags {
42,
i64
);
}
}
#[test]
fn if_guard_pattern_true() {
#[test]
fn if_guard_pattern_true() {
assert_evals_to!(
indoc!(
r#"
@ -507,10 +501,10 @@ mod gen_tags {
42,
i64
);
}
}
#[test]
fn if_guard_exhaustiveness() {
#[test]
fn if_guard_exhaustiveness() {
assert_evals_to!(
indoc!(
r#"
@ -525,10 +519,10 @@ mod gen_tags {
42,
i64
);
}
}
#[test]
fn when_on_enum() {
#[test]
fn when_on_enum() {
assert_evals_to!(
indoc!(
r#"
@ -546,10 +540,10 @@ mod gen_tags {
1,
i64
);
}
}
#[test]
fn pattern_matching_unit() {
#[test]
fn pattern_matching_unit() {
assert_evals_to!(
indoc!(
r#"
@ -604,10 +598,10 @@ mod gen_tags {
42,
i64
);
}
}
#[test]
fn one_element_tag() {
#[test]
fn one_element_tag() {
assert_evals_to!(
indoc!(
r#"
@ -620,10 +614,10 @@ mod gen_tags {
2,
i64
);
}
}
#[test]
fn nested_tag_union() {
#[test]
fn nested_tag_union() {
assert_evals_to!(
indoc!(
r#"
@ -641,9 +635,9 @@ mod gen_tags {
(0, (0, 41)),
(i64, (i64, i64))
);
}
#[test]
fn unit_type() {
}
#[test]
fn unit_type() {
assert_evals_to!(
indoc!(
r#"
@ -658,10 +652,10 @@ mod gen_tags {
(),
()
);
}
}
#[test]
fn nested_record_load() {
#[test]
fn nested_record_load() {
assert_evals_to!(
indoc!(
r#"
@ -675,10 +669,10 @@ mod gen_tags {
5,
i64
);
}
}
#[test]
fn join_point_if() {
#[test]
fn join_point_if() {
assert_evals_to!(
indoc!(
r#"
@ -691,10 +685,10 @@ mod gen_tags {
1,
i64
);
}
}
#[test]
fn join_point_when() {
#[test]
fn join_point_when() {
assert_evals_to!(
indoc!(
r#"
@ -716,10 +710,10 @@ mod gen_tags {
3.1,
f64
);
}
}
#[test]
fn join_point_with_cond_expr() {
#[test]
fn join_point_with_cond_expr() {
assert_evals_to!(
indoc!(
r#"
@ -754,10 +748,10 @@ mod gen_tags {
3,
i64
);
}
}
#[test]
fn alignment_in_single_tag_construction() {
#[test]
fn alignment_in_single_tag_construction() {
assert_evals_to!(indoc!("Three (1 == 1) 32"), (32i64, true), (i64, bool));
assert_evals_to!(
@ -765,10 +759,10 @@ mod gen_tags {
(32i64, true, 2u8),
(i64, bool, u8)
);
}
}
#[test]
fn alignment_in_single_tag_pattern_match() {
#[test]
fn alignment_in_single_tag_pattern_match() {
assert_evals_to!(
indoc!(
r"#
@ -796,10 +790,10 @@ mod gen_tags {
(32i64, true, 2u8),
(i64, bool, u8)
);
}
}
#[test]
fn alignment_in_multi_tag_construction() {
#[test]
fn alignment_in_multi_tag_construction() {
assert_evals_to!(
indoc!(
r"#
@ -826,10 +820,10 @@ mod gen_tags {
(1, 32i64, true, 2u8),
(i64, i64, bool, u8)
);
}
}
#[test]
fn alignment_in_multi_tag_pattern_match() {
#[test]
fn alignment_in_multi_tag_pattern_match() {
assert_evals_to!(
indoc!(
r"#
@ -864,11 +858,11 @@ mod gen_tags {
(32i64, true, 2u8),
(i64, bool, u8)
);
}
}
#[test]
#[ignore]
fn phantom_polymorphic() {
#[test]
#[ignore]
fn phantom_polymorphic() {
// see https://github.com/rtfeldman/roc/issues/786 and below
assert_evals_to!(
indoc!(
@ -889,11 +883,11 @@ mod gen_tags {
(0, 0),
(i64, i64)
);
}
}
#[test]
#[ignore]
fn phantom_polymorphic_record() {
#[test]
#[ignore]
fn phantom_polymorphic_record() {
// see https://github.com/rtfeldman/roc/issues/786
// also seemed to hit an issue where we check whether `add`
// has a Closure layout while the type is not fully specialized yet
@ -916,10 +910,10 @@ mod gen_tags {
(0, 0),
(i64, i64)
);
}
}
#[test]
fn result_never() {
#[test]
fn result_never() {
assert_evals_to!(
indoc!(
r"#
@ -937,10 +931,10 @@ mod gen_tags {
4,
i64
);
}
}
#[test]
fn nested_recursive_literal() {
#[test]
fn nested_recursive_literal() {
assert_evals_to!(
indoc!(
r"#
@ -956,10 +950,10 @@ mod gen_tags {
&i64,
|x: &i64| *x
);
}
}
#[test]
fn newtype_wrapper() {
#[test]
fn newtype_wrapper() {
assert_evals_to!(
indoc!(
r#"
@ -979,5 +973,4 @@ mod gen_tags {
&i64,
|x: &i64| *x
);
}
}

View file

@ -29,6 +29,9 @@ pub fn test_builtin_defs(symbol: Symbol, var_store: &mut VarStore) -> Option<Def
}
}
// this is not actually dead code, but only used by cfg_test modules
// so "normally" it is dead, only at testing time is it used
#[allow(dead_code)]
pub fn helper<'a>(
arena: &'a bumpalo::Bump,
src: &str,

View file

@ -4,6 +4,14 @@
// we actually want to compare against the literal float bits
#![allow(clippy::clippy::float_cmp)]
pub mod gen_tags;
pub mod gen_dict;
pub mod gen_hash;
pub mod gen_list;
pub mod gen_num;
pub mod gen_primitives;
pub mod gen_records;
pub mod gen_result;
pub mod gen_set;
pub mod gen_str;
pub mod gen_tags;
mod helpers;