remove dict/set tests for now

This commit is contained in:
Folkert 2023-03-08 13:54:08 +01:00
parent a0276f1a13
commit 69b2e03a04
No known key found for this signature in database
GPG Key ID: 1F17F6FFD112B97C
7 changed files with 0 additions and 230 deletions

View File

@ -1,10 +0,0 @@
app "app"
packages { pf: "platform.roc" }
imports []
provides [main] to pf
main =
Dict.empty {}
|> Dict.insert "foo" "this will be overwritten"
|> Dict.insert "baz" "blah"
|> Dict.insert "foo" "bar"

View File

@ -1,9 +0,0 @@
platform "test-platform"
requires {} { main : _ }
exposes []
packages {}
imports []
provides [mainForHost]
mainForHost : Dict Str Str
mainForHost = main

View File

@ -1,93 +0,0 @@
mod test_glue;
use roc_std::{RocDict, RocStr};
extern "C" {
#[link_name = "roc__mainForHost_1_exposed_generic"]
fn roc_main(_: *mut RocDict<RocStr, RocStr>);
}
#[no_mangle]
pub extern "C" fn rust_main() -> i32 {
use std::cmp::Ordering;
use std::collections::hash_set::HashSet;
let dict = unsafe {
let mut ret: core::mem::MaybeUninit<RocDict<RocStr, RocStr>> =
core::mem::MaybeUninit::uninit();
roc_main(ret.as_mut_ptr());
ret.assume_init()
};
// Verify that it has all the expected traits.
assert!(dict == dict); // PartialEq
assert_eq!(dict.len(), 2); // len
assert!(dict.clone() == dict.clone()); // Clone
assert!(dict.partial_cmp(&dict) == Some(Ordering::Equal)); // PartialOrd
assert!(dict.cmp(&dict) == Ordering::Equal); // Ord
let mut set = HashSet::new();
set.insert(dict.clone()); // Eq, Hash
set.insert(dict.clone());
assert_eq!(set.len(), 1);
println!("dict was: {:?}", dict); // Debug
// Exit code
0
}
// Externs required by roc_std and by the Roc app
use core::ffi::c_void;
use std::ffi::CStr;
use std::os::raw::c_char;
#[no_mangle]
pub unsafe extern "C" fn roc_alloc(size: usize, _alignment: u32) -> *mut c_void {
return libc::malloc(size);
}
#[no_mangle]
pub unsafe extern "C" fn roc_realloc(
c_ptr: *mut c_void,
new_size: usize,
_old_size: usize,
_alignment: u32,
) -> *mut c_void {
return libc::realloc(c_ptr, new_size);
}
#[no_mangle]
pub unsafe extern "C" fn roc_dealloc(c_ptr: *mut c_void, _alignment: u32) {
return libc::free(c_ptr);
}
#[no_mangle]
pub unsafe extern "C" fn roc_panic(c_ptr: *mut c_void, tag_id: u32) {
match tag_id {
0 => {
let slice = CStr::from_ptr(c_ptr as *const c_char);
let string = slice.to_str().unwrap();
eprintln!("Roc hit a panic: {}", string);
std::process::exit(1);
}
_ => todo!(),
}
}
#[no_mangle]
pub unsafe extern "C" fn roc_memcpy(dst: *mut c_void, src: *mut c_void, n: usize) -> *mut c_void {
libc::memcpy(dst, src, n)
}
#[no_mangle]
pub unsafe extern "C" fn roc_memset(dst: *mut c_void, c: i32, n: usize) -> *mut c_void {
libc::memset(dst, c, n)
}

View File

@ -1,11 +0,0 @@
app "app"
packages { pf: "platform.roc" }
imports []
provides [main] to pf
main =
Set.empty {}
|> Set.insert "foo"
|> Set.insert "bar"
|> Set.insert "foo"
|> Set.insert "baz"

View File

@ -1,9 +0,0 @@
platform "test-platform"
requires {} { main : _ }
exposes []
packages {}
imports []
provides [mainForHost]
mainForHost : Set Str
mainForHost = main

View File

@ -1,92 +0,0 @@
mod test_glue;
use roc_std::{RocSet, RocStr};
extern "C" {
#[link_name = "roc__mainForHost_1_exposed_generic"]
fn roc_main(_: *mut RocSet<RocStr>);
}
#[no_mangle]
pub extern "C" fn rust_main() -> i32 {
use std::cmp::Ordering;
use std::collections::hash_set::HashSet;
let set = unsafe {
let mut ret: core::mem::MaybeUninit<RocSet<RocStr>> = core::mem::MaybeUninit::uninit();
roc_main(ret.as_mut_ptr());
ret.assume_init()
};
// Verify that it has all the expected traits.
assert!(set == set); // PartialEq
assert_eq!(set.len(), 3); // len
assert!(set.clone() == set.clone()); // Clone
assert!(set.partial_cmp(&set) == Some(Ordering::Equal)); // PartialOrd
assert!(set.cmp(&set) == Ordering::Equal); // Ord
let mut hash_set = HashSet::new();
hash_set.insert(set.clone()); // Eq, Hash
hash_set.insert(set.clone());
assert_eq!(hash_set.len(), 1);
println!("set was: {:?}", set); // Debug
// Exit code
0
}
// Externs required by roc_std and by the Roc app
use core::ffi::c_void;
use std::ffi::CStr;
use std::os::raw::c_char;
#[no_mangle]
pub unsafe extern "C" fn roc_alloc(size: usize, _alignment: u32) -> *mut c_void {
return libc::malloc(size);
}
#[no_mangle]
pub unsafe extern "C" fn roc_realloc(
c_ptr: *mut c_void,
new_size: usize,
_old_size: usize,
_alignment: u32,
) -> *mut c_void {
return libc::realloc(c_ptr, new_size);
}
#[no_mangle]
pub unsafe extern "C" fn roc_dealloc(c_ptr: *mut c_void, _alignment: u32) {
return libc::free(c_ptr);
}
#[no_mangle]
pub unsafe extern "C" fn roc_panic(c_ptr: *mut c_void, tag_id: u32) {
match tag_id {
0 => {
let slice = CStr::from_ptr(c_ptr as *const c_char);
let string = slice.to_str().unwrap();
eprintln!("Roc hit a panic: {}", string);
std::process::exit(1);
}
_ => todo!(),
}
}
#[no_mangle]
pub unsafe extern "C" fn roc_memcpy(dst: *mut c_void, src: *mut c_void, n: usize) -> *mut c_void {
libc::memcpy(dst, src, n)
}
#[no_mangle]
pub unsafe extern "C" fn roc_memset(dst: *mut c_void, c: i32, n: usize) -> *mut c_void {
libc::memset(dst, c, n)
}

View File

@ -72,12 +72,6 @@ mod glue_cli_run {
fixtures! {
basic_record:"basic-record" => "Record was: MyRcd { b: 42, a: 1995 }\n",
nested_record:"nested-record" => "Record was: Outer { y: \"foo\", z: [1, 2], x: Inner { b: 24.0, a: 5 } }\n",
dict:"dict" => indoc!(r#"
dict was: RocDict {"foo": "bar", "baz": "blah"}
"#),
set:"set" => indoc!(r#"
set was: RocSet {"foo", "bar", "baz"}
"#),
enumeration:"enumeration" => "tag_union was: MyEnum::Foo, Bar is: MyEnum::Bar, Baz is: MyEnum::Baz\n",
union_with_padding:"union-with-padding" => indoc!(r#"
tag_union was: NonRecursive::Foo("This is a test")