mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-04 12:18:19 +00:00
Get tests passing
Add roc_dbg to some platforms. Also start updating some roc_panic impls.
This commit is contained in:
parent
e6cc43492a
commit
f5fb01fd53
17 changed files with 191 additions and 47 deletions
|
@ -36,6 +36,7 @@ extern "C" {
|
|||
) -> *mut c_void;
|
||||
pub fn roc_dealloc(ptr: *mut c_void, alignment: u32);
|
||||
pub fn roc_panic(c_ptr: *mut c_void, tag_id: u32);
|
||||
pub fn roc_dbg(loc: *mut c_void, msg: *mut c_void);
|
||||
pub fn roc_memset(dst: *mut c_void, c: i32, n: usize) -> *mut c_void;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,18 +32,14 @@ pub unsafe extern "C" fn roc_dealloc(c_ptr: *mut c_void, _alignment: u32) {
|
|||
|
||||
#[cfg(test)]
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn roc_panic(c_ptr: *mut c_void, tag_id: u32) {
|
||||
use std::ffi::CStr;
|
||||
use std::os::raw::c_char;
|
||||
pub unsafe extern "C" fn roc_panic(msg: *mut roc_std::RocStr, _tag_id: u32) {
|
||||
panic!("roc_panic during test: {}", &*msg);
|
||||
}
|
||||
|
||||
match tag_id {
|
||||
0 => {
|
||||
let c_str = CStr::from_ptr(c_ptr as *const c_char);
|
||||
let string = c_str.to_str().unwrap();
|
||||
panic!("roc_panic during test: {string}");
|
||||
}
|
||||
_ => todo!(),
|
||||
}
|
||||
#[cfg(test)]
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn roc_dbg(loc: *mut roc_std::RocStr, msg: *mut roc_std::RocStr) {
|
||||
eprintln!("[{}] {}", &*loc, &*msg);
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue