Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
tensorbase/crates/base/tests/proc_macro_tests.rs
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
60 lines (49 sloc)
1.78 KB
This file contains 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
// #![recursion_limit="512"] //macros bang? | |
use base::strings::s; | |
use base::{with_timer, with_timer_print, debug}; | |
use std::{thread, time}; | |
#[test] | |
fn integ_test_timing() { | |
let ten_millis = time::Duration::from_millis(10); | |
with_timer! {t0, | |
thread::sleep(ten_millis); | |
} | |
println!("t0: {:?}", t0.elapsed()); | |
assert!((t0.elapsed() - ten_millis) < time::Duration::from_millis(1)); | |
with_timer_print! {t1, | |
thread::sleep(ten_millis); | |
thread::sleep(ten_millis); | |
} | |
assert!( | |
(t1.elapsed() - ten_millis - ten_millis) | |
< time::Duration::from_millis(1) | |
); | |
} | |
#[test] | |
fn integ_test_str() { | |
let dsadsa = "Test"; | |
let some_float = 123.45; | |
let some_int = 123456789101112u64; | |
let s = s! { let ten_millis=1 | |
; }; | |
assert_eq!(s, "let ten_millis=1\n ;"); | |
let s = s!(class $dsadsa$1 { float x = $some_float$; }); | |
assert_eq!(s, "class Test1 { float x = 123.45; }"); | |
let typ = "long long"; | |
let s = s!(class $dsadsa$1 { float x = $some_float$; $typ$ x }); | |
assert_eq!(s, "class Test1 { float x = 123.45; long long x }"); | |
let dsadsa = String::from("Test2"); | |
let s = s!(class $dsadsa$1 { float x = $some_float$; $typ$ x =$some_int$ }); | |
assert_eq!(s, "class Test21 { float x = 123.45; long long x =123456789101112 }"); | |
let mut class_name = String::from("Test"); | |
// let member_name = String::from("var"); | |
let s = s!(class ${class_name.push('1');class_name}$ { }); | |
// debug!(&s); | |
assert_eq!(s, "class Test1 { }"); | |
let mut class_name = String::from("Test"); | |
let s = s!(class ${class_name.push('1');class_name}$ { }); | |
// let f = s!(float $String::from("var")$ = $some_float$;); | |
// let ss = s!(class { ${f}$}); | |
// // debug!(&s); | |
// assert_eq!(s, "class Test1 { }"); | |
} |