92 lines
1.5 KiB
Rust
92 lines
1.5 KiB
Rust
#![allow(unused)]
|
|
|
|
extern crate test;
|
|
|
|
use hashbrown::{HashMap, HashSet};
|
|
|
|
use inkwell::context::Context;
|
|
|
|
use ecow::EcoString;
|
|
|
|
use crate::ir::downgrade;
|
|
use super::JITContext;
|
|
use crate::ty::common::Const;
|
|
use crate::ty::public::*;
|
|
|
|
#[inline]
|
|
fn test_expr(expr: &str, expected: Value) {
|
|
todo!()
|
|
}
|
|
|
|
macro_rules! map {
|
|
($($k:expr => $v:expr),*) => {
|
|
{
|
|
#[allow(unused_mut)]
|
|
let mut m = HashMap::new();
|
|
$(
|
|
m.insert($k, $v);
|
|
)*
|
|
m
|
|
}
|
|
};
|
|
}
|
|
|
|
macro_rules! thunk {
|
|
() => {
|
|
Value::Thunk
|
|
};
|
|
}
|
|
|
|
macro_rules! int {
|
|
($e:expr) => {
|
|
Value::Const(Const::Int($e))
|
|
};
|
|
}
|
|
|
|
macro_rules! float {
|
|
($e:expr) => {
|
|
Value::Const(Const::Float($e as f64))
|
|
};
|
|
}
|
|
|
|
macro_rules! boolean {
|
|
($e:expr) => {
|
|
Value::Const(Const::Bool($e))
|
|
};
|
|
}
|
|
|
|
macro_rules! string {
|
|
($e:expr) => {
|
|
Value::Const(Const::String(EcoString::from($e)))
|
|
};
|
|
}
|
|
|
|
macro_rules! symbol {
|
|
($e:expr) => {
|
|
Symbol::from($e.to_string())
|
|
};
|
|
}
|
|
|
|
macro_rules! list {
|
|
($($x:tt)*) => (
|
|
Value::List(List::new(vec![$($x)*]))
|
|
);
|
|
}
|
|
|
|
macro_rules! attrs {
|
|
($($x:tt)*) => (
|
|
Value::AttrSet(AttrSet::new(map!{$($x)*}))
|
|
)
|
|
}
|
|
|
|
#[test]
|
|
fn test_jit_const() {
|
|
// test_expr("let f = _: 1; in (f 1) + (f 1)", int!(2));
|
|
test_expr("let f = _: 1; in (f 1) == (f 1)", boolean!(true));
|
|
}
|
|
|
|
#[test]
|
|
fn test_arith() {
|
|
test_expr("let f = _: -(-1); in (f 1) + (f 1)", int!(2));
|
|
}
|