This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[cfg(test)] | |
mod tests { | |
use super::*; | |
use std::ffi::CString; | |
#[test] | |
fn test_ffi_compile_success() { | |
let src = CString::new("(+ 1 2)").unwrap(); | |
unsafe { | |
let result_ptr = metta_compile(src.as_ptr()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[cfg(test)] | |
mod tests { | |
use super::*; | |
#[test] | |
fn test_lexer_basic() { | |
let mut lexer = Lexer::new("(+ 1 2)"); | |
let tokens = lexer.tokenize().unwrap(); | |
assert_eq!(tokens.len(), 6); // (, +, 1, 2, ), EOF | |
assert_eq!(tokens[0], Token::LParen); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[cfg(test)] | |
mod tests { | |
use super::*; | |
#[test] | |
fn test_compile_empty_input() { | |
let result = compile(""); | |
assert!(result.is_ok()); | |
let state = result.unwrap(); | |
assert_eq!(state.pending_exprs.len(), 0); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[cfg(test)] | |
mod tests { | |
use super::*; | |
use backend::*; | |
#[test] | |
fn test_compile_simple() { | |
let result = compile("(+ 1 2)"); | |
assert!(result.is_ok()); | |
} |