mirror of
https://github.com/roc-lang/roc.git
synced 2024-09-22 00:09:33 +03:00
Merge remote-tracking branch 'origin/trunk' into list-replace
This commit is contained in:
commit
7c6c9b52a9
@ -25,7 +25,49 @@ use roc_parse::{
|
||||
};
|
||||
use roc_region::all::{Loc, Region};
|
||||
|
||||
fn flatten_directories(files: std::vec::Vec<PathBuf>) -> std::vec::Vec<PathBuf> {
|
||||
let mut to_flatten = files;
|
||||
let mut files = vec![];
|
||||
|
||||
while let Some(path) = to_flatten.pop() {
|
||||
if path.is_dir() {
|
||||
match path.read_dir() {
|
||||
Ok(directory) => {
|
||||
for item in directory {
|
||||
match item {
|
||||
Ok(file) => {
|
||||
let file_path = file.path();
|
||||
if file_path.is_dir() {
|
||||
to_flatten.push(file_path);
|
||||
} else if file_path.ends_with(".roc") {
|
||||
files.push(file_path);
|
||||
}
|
||||
}
|
||||
|
||||
Err(error) => internal_error!(
|
||||
"There was an error while trying to read a file from a directory: {:?}",
|
||||
error
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Err(error) => internal_error!(
|
||||
"There was an error while trying to read the contents of a directory: {:?}",
|
||||
error
|
||||
),
|
||||
}
|
||||
} else {
|
||||
files.push(path)
|
||||
}
|
||||
}
|
||||
|
||||
files
|
||||
}
|
||||
|
||||
pub fn format(files: std::vec::Vec<PathBuf>, mode: FormatMode) -> Result<(), String> {
|
||||
let files = flatten_directories(files);
|
||||
|
||||
for file in files {
|
||||
let arena = Bump::new();
|
||||
|
||||
|
@ -5,6 +5,7 @@ use build::{BuildOutcome, BuiltFile};
|
||||
use bumpalo::Bump;
|
||||
use clap::{App, AppSettings, Arg, ArgMatches};
|
||||
use roc_build::link::LinkType;
|
||||
use roc_error_macros::user_error;
|
||||
use roc_load::file::LoadingProblem;
|
||||
use roc_mono::ir::OptLevel;
|
||||
use std::env;
|
||||
@ -31,6 +32,7 @@ pub const CMD_FORMAT: &str = "format";
|
||||
pub const FLAG_DEBUG: &str = "debug";
|
||||
pub const FLAG_DEV: &str = "dev";
|
||||
pub const FLAG_OPTIMIZE: &str = "optimize";
|
||||
pub const FLAG_OPT_SIZE: &str = "opt-size";
|
||||
pub const FLAG_LIB: &str = "lib";
|
||||
pub const FLAG_BACKEND: &str = "backend";
|
||||
pub const FLAG_TIME: &str = "time";
|
||||
@ -61,6 +63,12 @@ pub fn build_app<'a>() -> App<'a> {
|
||||
.about("Optimize your compiled Roc program to run faster. (Optimization takes time to complete.)")
|
||||
.required(false),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(FLAG_OPT_SIZE)
|
||||
.long(FLAG_OPT_SIZE)
|
||||
.about("Optimize your compiled Roc program to have a small binary size. (Optimization takes time to complete.)")
|
||||
.required(false),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(FLAG_DEV)
|
||||
.long(FLAG_DEV)
|
||||
@ -166,12 +174,18 @@ pub fn build_app<'a>() -> App<'a> {
|
||||
.requires(ROC_FILE)
|
||||
.required(false),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(FLAG_DEV)
|
||||
.long(FLAG_DEV)
|
||||
.about("Make compilation as fast as possible. (Runtime performance may suffer)")
|
||||
.required(false),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(FLAG_OPT_SIZE)
|
||||
.long(FLAG_OPT_SIZE)
|
||||
.about("Optimize your compiled Roc program to have a small binary size. (Optimization takes time to complete.)")
|
||||
.required(false),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(FLAG_DEV)
|
||||
.long(FLAG_DEV)
|
||||
.about("Make compilation as fast as possible. (Runtime performance may suffer)")
|
||||
.required(false),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(FLAG_DEBUG)
|
||||
.long(FLAG_DEBUG)
|
||||
@ -272,12 +286,14 @@ pub fn build(matches: &ArgMatches, config: BuildConfig) -> io::Result<i32> {
|
||||
let original_cwd = std::env::current_dir()?;
|
||||
let opt_level = match (
|
||||
matches.is_present(FLAG_OPTIMIZE),
|
||||
matches.is_present(FLAG_OPT_SIZE),
|
||||
matches.is_present(FLAG_DEV),
|
||||
) {
|
||||
(true, false) => OptLevel::Optimize,
|
||||
(true, true) => panic!("development cannot be optimized!"),
|
||||
(false, true) => OptLevel::Development,
|
||||
(false, false) => OptLevel::Normal,
|
||||
(true, false, false) => OptLevel::Optimize,
|
||||
(false, true, false) => OptLevel::Size,
|
||||
(false, false, true) => OptLevel::Development,
|
||||
(false, false, false) => OptLevel::Normal,
|
||||
_ => user_error!("build can be only one of `--dev`, `--optimize`, or `--opt-size`"),
|
||||
};
|
||||
let emit_debug_info = matches.is_present(FLAG_DEBUG);
|
||||
let emit_timings = matches.is_present(FLAG_TIME);
|
||||
|
@ -12,8 +12,8 @@ extern crate indoc;
|
||||
#[cfg(test)]
|
||||
mod cli_run {
|
||||
use cli_utils::helpers::{
|
||||
example_file, examples_dir, extract_valgrind_errors, fixture_file, known_bad_file, run_cmd,
|
||||
run_roc, run_with_valgrind, ValgrindError, ValgrindErrorXWhat,
|
||||
example_file, examples_dir, extract_valgrind_errors, fixture_file, fixtures_dir,
|
||||
known_bad_file, run_cmd, run_roc, run_with_valgrind, ValgrindError, ValgrindErrorXWhat,
|
||||
};
|
||||
use roc_test_utils::assert_multiline_str_eq;
|
||||
use serial_test::serial;
|
||||
@ -884,6 +884,15 @@ mod cli_run {
|
||||
fn format_check_reformatting_needed() {
|
||||
check_format_check_as_expected(&fixture_file("format", "NotFormatted.roc"), false);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn format_check_folders() {
|
||||
// This fails, because "NotFormatted.roc" is present in this folder
|
||||
check_format_check_as_expected(&fixtures_dir("format"), false);
|
||||
|
||||
// This doesn't fail, since only "Formatted.roc" is present in this folder
|
||||
check_format_check_as_expected(&fixtures_dir("format/formatted_directory"), true);
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
|
6
cli/tests/fixtures/format/formatted_directory/Formatted.roc
vendored
Normal file
6
cli/tests/fixtures/format/formatted_directory/Formatted.roc
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
app "formatted"
|
||||
packages { pf: "platform" } imports []
|
||||
provides [ main ] to pf
|
||||
|
||||
main : Str
|
||||
main = Dep1.value1 {}
|
@ -137,6 +137,8 @@ pub fn build_zig_host_native(
|
||||
|
||||
if matches!(opt_level, OptLevel::Optimize) {
|
||||
command.args(&["-O", "ReleaseSafe"]);
|
||||
} else if matches!(opt_level, OptLevel::Size) {
|
||||
command.args(&["-O", "ReleaseSmall"]);
|
||||
}
|
||||
command.output().unwrap()
|
||||
}
|
||||
@ -231,6 +233,8 @@ pub fn build_zig_host_native(
|
||||
]);
|
||||
if matches!(opt_level, OptLevel::Optimize) {
|
||||
command.args(&["-O", "ReleaseSafe"]);
|
||||
} else if matches!(opt_level, OptLevel::Size) {
|
||||
command.args(&["-O", "ReleaseSmall"]);
|
||||
}
|
||||
command.output().unwrap()
|
||||
}
|
||||
@ -282,6 +286,8 @@ pub fn build_zig_host_wasm32(
|
||||
]);
|
||||
if matches!(opt_level, OptLevel::Optimize) {
|
||||
command.args(&["-O", "ReleaseSafe"]);
|
||||
} else if matches!(opt_level, OptLevel::Size) {
|
||||
command.args(&["-O", "ReleaseSmall"]);
|
||||
}
|
||||
command.output().unwrap()
|
||||
}
|
||||
@ -317,7 +323,9 @@ pub fn build_c_host_native(
|
||||
command.args(&["-fPIC", "-c"]);
|
||||
}
|
||||
if matches!(opt_level, OptLevel::Optimize) {
|
||||
command.arg("-O2");
|
||||
command.arg("-O3");
|
||||
} else if matches!(opt_level, OptLevel::Size) {
|
||||
command.arg("-Os");
|
||||
}
|
||||
command.output().unwrap()
|
||||
}
|
||||
@ -351,6 +359,8 @@ pub fn build_swift_host_native(
|
||||
|
||||
if matches!(opt_level, OptLevel::Optimize) {
|
||||
command.arg("-O");
|
||||
} else if matches!(opt_level, OptLevel::Size) {
|
||||
command.arg("-Osize");
|
||||
}
|
||||
|
||||
command.output().unwrap()
|
||||
@ -456,18 +466,18 @@ pub fn rebuild_host(
|
||||
} else if cargo_host_src.exists() {
|
||||
// Compile and link Cargo.toml, if it exists
|
||||
let cargo_dir = host_input_path.parent().unwrap();
|
||||
let cargo_out_dir =
|
||||
cargo_dir
|
||||
.join("target")
|
||||
.join(if matches!(opt_level, OptLevel::Optimize) {
|
||||
"release"
|
||||
} else {
|
||||
"debug"
|
||||
});
|
||||
let cargo_out_dir = cargo_dir.join("target").join(
|
||||
if matches!(opt_level, OptLevel::Optimize | OptLevel::Size) {
|
||||
"release"
|
||||
} else {
|
||||
"debug"
|
||||
},
|
||||
);
|
||||
|
||||
let mut command = Command::new("cargo");
|
||||
command.arg("build").current_dir(cargo_dir);
|
||||
if matches!(opt_level, OptLevel::Optimize) {
|
||||
// Rust doesn't expose size without editing the cargo.toml. Instead just use release.
|
||||
if matches!(opt_level, OptLevel::Optimize | OptLevel::Size) {
|
||||
command.arg("--release");
|
||||
}
|
||||
let source_file = if shared_lib_path.is_some() {
|
||||
@ -533,6 +543,8 @@ pub fn rebuild_host(
|
||||
]);
|
||||
if matches!(opt_level, OptLevel::Optimize) {
|
||||
command.arg("-O");
|
||||
} else if matches!(opt_level, OptLevel::Size) {
|
||||
command.arg("-C opt-level=s");
|
||||
}
|
||||
let output = command.output().unwrap();
|
||||
|
||||
|
@ -199,7 +199,7 @@ pub fn gen_from_mono_module(
|
||||
emit_debug_info: bool,
|
||||
) -> CodeGenTiming {
|
||||
match opt_level {
|
||||
OptLevel::Normal | OptLevel::Optimize => gen_from_mono_module_llvm(
|
||||
OptLevel::Normal | OptLevel::Size | OptLevel::Optimize => gen_from_mono_module_llvm(
|
||||
arena,
|
||||
loaded,
|
||||
roc_file_path,
|
||||
|
@ -114,6 +114,8 @@ pub fn target_machine(
|
||||
pub fn convert_opt_level(level: OptLevel) -> OptimizationLevel {
|
||||
match level {
|
||||
OptLevel::Development | OptLevel::Normal => OptimizationLevel::None,
|
||||
// Default is O2/Os. If we want Oz, we have to explicitly turn of loop vectorization as well.
|
||||
OptLevel::Size => OptimizationLevel::Default,
|
||||
OptLevel::Optimize => OptimizationLevel::Aggressive,
|
||||
}
|
||||
}
|
||||
|
@ -657,35 +657,43 @@ pub fn construct_optimization_passes<'a>(
|
||||
OptLevel::Development | OptLevel::Normal => {
|
||||
pmb.set_optimization_level(OptimizationLevel::None);
|
||||
}
|
||||
OptLevel::Size => {
|
||||
pmb.set_optimization_level(OptimizationLevel::Default);
|
||||
// TODO: For some usecase, like embedded, it is useful to expose this and tune it.
|
||||
pmb.set_inliner_with_threshold(50);
|
||||
}
|
||||
OptLevel::Optimize => {
|
||||
pmb.set_optimization_level(OptimizationLevel::Aggressive);
|
||||
// this threshold seems to do what we want
|
||||
pmb.set_inliner_with_threshold(275);
|
||||
|
||||
// TODO figure out which of these actually help
|
||||
|
||||
// function passes
|
||||
|
||||
fpm.add_cfg_simplification_pass();
|
||||
mpm.add_cfg_simplification_pass();
|
||||
|
||||
fpm.add_jump_threading_pass();
|
||||
mpm.add_jump_threading_pass();
|
||||
|
||||
fpm.add_memcpy_optimize_pass(); // this one is very important
|
||||
|
||||
fpm.add_licm_pass();
|
||||
|
||||
// turn invoke into call
|
||||
mpm.add_prune_eh_pass();
|
||||
|
||||
// remove unused global values (often the `_wrapper` can be removed)
|
||||
mpm.add_global_dce_pass();
|
||||
|
||||
mpm.add_function_inlining_pass();
|
||||
}
|
||||
}
|
||||
|
||||
// Add optimization passes for Size and Optimize.
|
||||
if matches!(opt_level, OptLevel::Size | OptLevel::Optimize) {
|
||||
// TODO figure out which of these actually help
|
||||
|
||||
// function passes
|
||||
|
||||
fpm.add_cfg_simplification_pass();
|
||||
mpm.add_cfg_simplification_pass();
|
||||
|
||||
fpm.add_jump_threading_pass();
|
||||
mpm.add_jump_threading_pass();
|
||||
|
||||
fpm.add_memcpy_optimize_pass(); // this one is very important
|
||||
|
||||
fpm.add_licm_pass();
|
||||
|
||||
// turn invoke into call
|
||||
mpm.add_prune_eh_pass();
|
||||
|
||||
// remove unused global values (often the `_wrapper` can be removed)
|
||||
mpm.add_global_dce_pass();
|
||||
|
||||
mpm.add_function_inlining_pass();
|
||||
}
|
||||
|
||||
pmb.populate_module_pass_manager(&mpm);
|
||||
pmb.populate_function_pass_manager(&fpm);
|
||||
|
||||
|
@ -245,7 +245,7 @@ where
|
||||
|
||||
match opt_level {
|
||||
OptLevel::Development | OptLevel::Normal => morphic_lib::solve_trivial(program),
|
||||
OptLevel::Optimize => morphic_lib::solve(program),
|
||||
OptLevel::Optimize | OptLevel::Size => morphic_lib::solve(program),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -90,6 +90,7 @@ macro_rules! return_on_layout_error_help {
|
||||
pub enum OptLevel {
|
||||
Development,
|
||||
Normal,
|
||||
Size,
|
||||
Optimize,
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ fn roc_list_construction() {
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
fn empty_list_literal() {
|
||||
assert_evals_to!("[]", RocList::from_slice(&[]), RocList<i64>);
|
||||
assert_evals_to!("[]", RocList::<i64>::from_slice(&[]), RocList<i64>);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -136,7 +136,7 @@ fn bool_list_literal() {
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
fn variously_sized_list_literals() {
|
||||
assert_evals_to!("[]", RocList::from_slice(&[]), RocList<i64>);
|
||||
assert_evals_to!("[]", RocList::<i64>::from_slice(&[]), RocList<i64>);
|
||||
assert_evals_to!("[1]", RocList::from_slice(&[1]), RocList<i64>);
|
||||
assert_evals_to!("[1, 2]", RocList::from_slice(&[1, 2]), RocList<i64>);
|
||||
assert_evals_to!("[1, 2, 3]", RocList::from_slice(&[1, 2, 3]), RocList<i64>);
|
||||
@ -177,12 +177,12 @@ fn list_take_first() {
|
||||
);
|
||||
assert_evals_to!(
|
||||
"List.takeFirst [1, 2, 3] 0",
|
||||
RocList::from_slice(&[]),
|
||||
RocList::<i64>::from_slice(&[]),
|
||||
RocList<i64>
|
||||
);
|
||||
assert_evals_to!(
|
||||
"List.takeFirst [] 1",
|
||||
RocList::from_slice(&[]),
|
||||
RocList::<i64>::from_slice(&[]),
|
||||
RocList<i64>
|
||||
);
|
||||
assert_evals_to!(
|
||||
@ -202,10 +202,14 @@ fn list_take_last() {
|
||||
);
|
||||
assert_evals_to!(
|
||||
"List.takeLast [1, 2, 3] 0",
|
||||
RocList::from_slice(&[]),
|
||||
RocList::<i64>::from_slice(&[]),
|
||||
RocList<i64>
|
||||
);
|
||||
assert_evals_to!(
|
||||
"List.takeLast [] 1",
|
||||
RocList::<i64>::from_slice(&[]),
|
||||
RocList<i64>
|
||||
);
|
||||
assert_evals_to!("List.takeLast [] 1", RocList::from_slice(&[]), RocList<i64>);
|
||||
assert_evals_to!(
|
||||
"List.takeLast [1,2] 5",
|
||||
RocList::from_slice(&[1, 2]),
|
||||
@ -233,17 +237,17 @@ fn list_sublist() {
|
||||
);
|
||||
assert_evals_to!(
|
||||
"List.sublist [1, 2, 3] { start: 3 , len: 2 } ",
|
||||
RocList::from_slice(&[]),
|
||||
RocList::<i64>::from_slice(&[]),
|
||||
RocList<i64>
|
||||
);
|
||||
assert_evals_to!(
|
||||
"List.sublist [] { start: 1 , len: 1 } ",
|
||||
RocList::from_slice(&[]),
|
||||
RocList::<i64>::from_slice(&[]),
|
||||
RocList<i64>
|
||||
);
|
||||
assert_evals_to!(
|
||||
"List.sublist [1, 2, 3] { start: 1 , len: 0 } ",
|
||||
RocList::from_slice(&[]),
|
||||
RocList::<i64>::from_slice(&[]),
|
||||
RocList<i64>
|
||||
);
|
||||
assert_evals_to!(
|
||||
@ -261,7 +265,7 @@ fn list_split() {
|
||||
list = List.split [1, 2, 3] 0
|
||||
list.before
|
||||
"#,
|
||||
RocList::from_slice(&[]),
|
||||
RocList::<i64>::from_slice(&[]),
|
||||
RocList<i64>
|
||||
);
|
||||
assert_evals_to!(
|
||||
@ -280,17 +284,26 @@ fn list_split() {
|
||||
);
|
||||
assert_evals_to!(
|
||||
"List.split [1, 2, 3] 3",
|
||||
(RocList::from_slice(&[1, 2, 3]), RocList::from_slice(&[]),),
|
||||
(
|
||||
RocList::from_slice(&[1, 2, 3]),
|
||||
RocList::<i64>::from_slice(&[]),
|
||||
),
|
||||
(RocList<i64>, RocList<i64>,)
|
||||
);
|
||||
assert_evals_to!(
|
||||
"List.split [1, 2, 3] 4",
|
||||
(RocList::from_slice(&[1, 2, 3]), RocList::from_slice(&[]),),
|
||||
(
|
||||
RocList::from_slice(&[1, 2, 3]),
|
||||
RocList::<i64>::from_slice(&[]),
|
||||
),
|
||||
(RocList<i64>, RocList<i64>,)
|
||||
);
|
||||
assert_evals_to!(
|
||||
"List.split [] 1",
|
||||
(RocList::from_slice(&[]), RocList::from_slice(&[]),),
|
||||
(
|
||||
RocList::<i64>::from_slice(&[]),
|
||||
RocList::<i64>::from_slice(&[]),
|
||||
),
|
||||
(RocList<i64>, RocList<i64>,)
|
||||
);
|
||||
}
|
||||
@ -302,8 +315,16 @@ fn list_drop() {
|
||||
RocList::from_slice(&[3]),
|
||||
RocList<i64>
|
||||
);
|
||||
assert_evals_to!("List.drop [] 1", RocList::from_slice(&[]), RocList<i64>);
|
||||
assert_evals_to!("List.drop [1,2] 5", RocList::from_slice(&[]), RocList<i64>);
|
||||
assert_evals_to!(
|
||||
"List.drop [] 1",
|
||||
RocList::<i64>::from_slice(&[]),
|
||||
RocList<i64>
|
||||
);
|
||||
assert_evals_to!(
|
||||
"List.drop [1,2] 5",
|
||||
RocList::<i64>::from_slice(&[]),
|
||||
RocList<i64>
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -319,8 +340,16 @@ fn list_drop_at() {
|
||||
RocList::from_slice(&[0, 0, 0]),
|
||||
RocList<i64>
|
||||
);
|
||||
assert_evals_to!("List.dropAt [] 1", RocList::from_slice(&[]), RocList<i64>);
|
||||
assert_evals_to!("List.dropAt [0] 0", RocList::from_slice(&[]), RocList<i64>);
|
||||
assert_evals_to!(
|
||||
"List.dropAt [] 1",
|
||||
RocList::<i64>::from_slice(&[]),
|
||||
RocList<i64>
|
||||
);
|
||||
assert_evals_to!(
|
||||
"List.dropAt [0] 0",
|
||||
RocList::<i64>::from_slice(&[]),
|
||||
RocList<i64>
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -341,7 +370,7 @@ fn list_intersperse() {
|
||||
List.intersperse [] 1
|
||||
"#
|
||||
),
|
||||
RocList::from_slice(&[]),
|
||||
RocList::<i64>::from_slice(&[]),
|
||||
RocList<i64>
|
||||
);
|
||||
}
|
||||
@ -380,7 +409,7 @@ fn list_drop_if_empty_list_of_int() {
|
||||
List.dropIf empty \_ -> True
|
||||
"#
|
||||
),
|
||||
RocList::from_slice(&[]),
|
||||
RocList::<i64>::from_slice(&[]),
|
||||
RocList<i64>
|
||||
);
|
||||
}
|
||||
@ -397,7 +426,7 @@ fn list_drop_if_empty_list() {
|
||||
List.dropIf [] alwaysTrue
|
||||
"#
|
||||
),
|
||||
RocList::from_slice(&[]),
|
||||
RocList::<i64>::from_slice(&[]),
|
||||
RocList<i64>
|
||||
);
|
||||
}
|
||||
@ -425,7 +454,7 @@ fn list_drop_if_always_true_for_non_empty_list() {
|
||||
List.dropIf [1,2,3,4,5,6,7,8] (\_ -> True)
|
||||
"#
|
||||
),
|
||||
RocList::from_slice(&[]),
|
||||
RocList::<i64>::from_slice(&[]),
|
||||
RocList<i64>
|
||||
);
|
||||
}
|
||||
@ -466,8 +495,16 @@ fn list_drop_last() {
|
||||
RocList::from_slice(&[1, 2]),
|
||||
RocList<i64>
|
||||
);
|
||||
assert_evals_to!("List.dropLast []", RocList::from_slice(&[]), RocList<i64>);
|
||||
assert_evals_to!("List.dropLast [0]", RocList::from_slice(&[]), RocList<i64>);
|
||||
assert_evals_to!(
|
||||
"List.dropLast []",
|
||||
RocList::<i64>::from_slice(&[]),
|
||||
RocList<i64>
|
||||
);
|
||||
assert_evals_to!(
|
||||
"List.dropLast [0]",
|
||||
RocList::<i64>::from_slice(&[]),
|
||||
RocList<i64>
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -500,14 +537,26 @@ fn list_drop_first() {
|
||||
RocList::from_slice(&[2, 3]),
|
||||
RocList<i64>
|
||||
);
|
||||
assert_evals_to!("List.dropFirst []", RocList::from_slice(&[]), RocList<i64>);
|
||||
assert_evals_to!("List.dropFirst [0]", RocList::from_slice(&[]), RocList<i64>);
|
||||
assert_evals_to!(
|
||||
"List.dropFirst []",
|
||||
RocList::<i64>::from_slice(&[]),
|
||||
RocList<i64>
|
||||
);
|
||||
assert_evals_to!(
|
||||
"List.dropFirst [0]",
|
||||
RocList::<i64>::from_slice(&[]),
|
||||
RocList<i64>
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
fn list_swap() {
|
||||
assert_evals_to!("List.swap [] 0 1", RocList::from_slice(&[]), RocList<i64>);
|
||||
assert_evals_to!(
|
||||
"List.swap [] 0 1",
|
||||
RocList::<i64>::from_slice(&[]),
|
||||
RocList<i64>
|
||||
);
|
||||
assert_evals_to!(
|
||||
"List.swap [ 0 ] 1 2",
|
||||
RocList::from_slice(&[0]),
|
||||
@ -780,7 +829,7 @@ fn list_keep_if_empty_list_of_int() {
|
||||
List.keepIf empty \_ -> True
|
||||
"#
|
||||
),
|
||||
RocList::from_slice(&[]),
|
||||
RocList::<i64>::from_slice(&[]),
|
||||
RocList<i64>
|
||||
);
|
||||
}
|
||||
@ -799,7 +848,7 @@ fn list_keep_if_empty_list() {
|
||||
List.keepIf [] alwaysTrue
|
||||
"#
|
||||
),
|
||||
RocList::from_slice(&[]),
|
||||
RocList::<i64>::from_slice(&[]),
|
||||
RocList<i64>
|
||||
);
|
||||
}
|
||||
@ -839,7 +888,7 @@ fn list_keep_if_always_false_for_non_empty_list() {
|
||||
List.keepIf [1,2,3,4,5,6,7,8] alwaysFalse
|
||||
"#
|
||||
),
|
||||
RocList::from_slice(&[]),
|
||||
RocList::<i64>::from_slice(&[]),
|
||||
RocList<i64>
|
||||
);
|
||||
}
|
||||
@ -889,7 +938,7 @@ fn list_map_on_empty_list_with_int_layout() {
|
||||
List.map empty (\x -> x)
|
||||
"#
|
||||
),
|
||||
RocList::from_slice(&[]),
|
||||
RocList::<i64>::from_slice(&[]),
|
||||
RocList<i64>
|
||||
);
|
||||
}
|
||||
@ -1000,7 +1049,7 @@ fn list_map_all_inline() {
|
||||
List.map [] (\x -> x > 0)
|
||||
"#
|
||||
),
|
||||
RocList::from_slice(&[]),
|
||||
RocList::<bool>::from_slice(&[]),
|
||||
RocList<bool>
|
||||
);
|
||||
}
|
||||
@ -1126,7 +1175,11 @@ fn list_map2_different_lengths() {
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
fn list_join_empty_list() {
|
||||
assert_evals_to!("List.join []", RocList::from_slice(&[]), RocList<i64>);
|
||||
assert_evals_to!(
|
||||
"List.join []",
|
||||
RocList::<i64>::from_slice(&[]),
|
||||
RocList<i64>
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -1208,7 +1261,7 @@ fn list_join_defined_empty_list() {
|
||||
fn list_join_all_empty_lists() {
|
||||
assert_evals_to!(
|
||||
"List.join [ [], [], [] ]",
|
||||
RocList::from_slice(&[]),
|
||||
RocList::<f64>::from_slice(&[]),
|
||||
RocList<f64>
|
||||
);
|
||||
}
|
||||
@ -1246,7 +1299,7 @@ fn list_repeat() {
|
||||
|
||||
assert_evals_to!(
|
||||
"List.repeat [] 2",
|
||||
RocList::from_slice(&[RocList::default(), RocList::default()]),
|
||||
RocList::from_slice(&[RocList::<i64>::default(), RocList::default()]),
|
||||
RocList<RocList<i64>>
|
||||
);
|
||||
|
||||
@ -1260,7 +1313,7 @@ fn list_repeat() {
|
||||
List.repeat noStrs 2
|
||||
"#
|
||||
),
|
||||
RocList::from_slice(&[RocList::default(), RocList::default()]),
|
||||
RocList::from_slice(&[RocList::<i64>::default(), RocList::default()]),
|
||||
RocList<RocList<i64>>
|
||||
);
|
||||
|
||||
@ -1300,7 +1353,7 @@ fn list_reverse_empty_list_of_int() {
|
||||
List.reverse emptyList
|
||||
"#
|
||||
),
|
||||
RocList::from_slice(&[]),
|
||||
RocList::<i64>::from_slice(&[]),
|
||||
RocList<i64>
|
||||
);
|
||||
}
|
||||
@ -1308,7 +1361,11 @@ fn list_reverse_empty_list_of_int() {
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
fn list_reverse_empty_list() {
|
||||
assert_evals_to!("List.reverse []", RocList::from_slice(&[]), RocList<i64>);
|
||||
assert_evals_to!(
|
||||
"List.reverse []",
|
||||
RocList::<i64>::from_slice(&[]),
|
||||
RocList<i64>
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -1328,7 +1385,7 @@ fn list_concat() {
|
||||
List.concat firstList secondList
|
||||
"#
|
||||
),
|
||||
RocList::from_slice(&[]),
|
||||
RocList::<i64>::from_slice(&[]),
|
||||
RocList<i64>
|
||||
);
|
||||
}
|
||||
@ -1336,7 +1393,11 @@ fn list_concat() {
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
fn list_concat_two_empty_lists() {
|
||||
assert_evals_to!("List.concat [] []", RocList::from_slice(&[]), RocList<i64>);
|
||||
assert_evals_to!(
|
||||
"List.concat [] []",
|
||||
RocList::<i64>::from_slice(&[]),
|
||||
RocList<i64>
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -1356,7 +1417,7 @@ fn list_concat_two_empty_lists_of_int() {
|
||||
List.concat firstList secondList
|
||||
"#
|
||||
),
|
||||
RocList::from_slice(&[]),
|
||||
RocList::<i64>::from_slice(&[]),
|
||||
RocList<i64>
|
||||
);
|
||||
}
|
||||
@ -2471,7 +2532,11 @@ fn cleanup_because_exception() {
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
fn list_range() {
|
||||
assert_evals_to!("List.range 0 -1", RocList::from_slice(&[]), RocList<i64>);
|
||||
assert_evals_to!(
|
||||
"List.range 0 -1",
|
||||
RocList::<i64>::from_slice(&[]),
|
||||
RocList<i64>
|
||||
);
|
||||
assert_evals_to!("List.range 0 0", RocList::from_slice(&[0]), RocList<i64>);
|
||||
assert_evals_to!(
|
||||
"List.range 0 5",
|
||||
@ -2485,7 +2550,7 @@ fn list_range() {
|
||||
fn list_sort_with() {
|
||||
assert_evals_to!(
|
||||
"List.sortWith [] Num.compare",
|
||||
RocList::from_slice(&[]),
|
||||
RocList::<i64>::from_slice(&[]),
|
||||
RocList<i64>
|
||||
);
|
||||
assert_evals_to!(
|
||||
@ -2503,7 +2568,11 @@ fn list_sort_with() {
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
fn list_sort_asc() {
|
||||
assert_evals_to!("List.sortAsc []", RocList::from_slice(&[]), RocList<i64>);
|
||||
assert_evals_to!(
|
||||
"List.sortAsc []",
|
||||
RocList::<i64>::from_slice(&[]),
|
||||
RocList<i64>
|
||||
);
|
||||
assert_evals_to!(
|
||||
"List.sortAsc [ 4,3,2,1 ]",
|
||||
RocList::from_slice(&[1, 2, 3, 4]),
|
||||
@ -2514,7 +2583,11 @@ fn list_sort_asc() {
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
fn list_sort_desc() {
|
||||
assert_evals_to!("List.sortDesc []", RocList::from_slice(&[]), RocList<i64>);
|
||||
assert_evals_to!(
|
||||
"List.sortDesc []",
|
||||
RocList::<i64>::from_slice(&[]),
|
||||
RocList<i64>
|
||||
);
|
||||
assert_evals_to!(
|
||||
"List.sortDesc [ 1,2,3,4 ]",
|
||||
RocList::from_slice(&[4, 3, 2, 1]),
|
||||
|
@ -238,7 +238,7 @@ fn from_list() {
|
||||
|> Set.toList
|
||||
"#
|
||||
),
|
||||
RocList::default(),
|
||||
RocList::<i64>::default(),
|
||||
RocList<i64>
|
||||
);
|
||||
}
|
||||
@ -254,7 +254,7 @@ fn from_list_void() {
|
||||
|> Set.toList
|
||||
"#
|
||||
),
|
||||
RocList::default(),
|
||||
RocList::<i64>::default(),
|
||||
RocList<i64>
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user