diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/kernel.rs | 70 | 
1 files changed, 42 insertions, 28 deletions
| diff --git a/src/kernel.rs b/src/kernel.rs index 6ec67ae..a6d8402 100644 --- a/src/kernel.rs +++ b/src/kernel.rs @@ -13,6 +13,7 @@  #![feature(trait_alias)]  #![feature(exclusive_range_pattern)]  #![feature(default_alloc_error_handler)] +#![feature(optimize_attribute)]  #![no_main]  #![no_std] @@ -75,35 +76,48 @@ fn kernel_main() -> ! {  	}  	#[cfg(feature="verbose")] +	run_verbose(); + +	loop { } +} + +fn run_verbose() { +	println!("U8: {:?}", mem::alloc::U8_GRAND_ALLOC);  	{ -		{ -			let a: Box<u8> = Box::new(1); -			println!("Box: {}", a); -		} -		{ -			let a: Box<u8> = Box::new(2); -			let b: Box<u8> = Box::new(3); -			let c: Box<u8> = Box::new(4); -			println!("Boxes: {}, {}, {}", a, b, c); -		} -		{ -			let a: Box<u8> = Box::new(5); -			let b: Box<u8> = Box::new(6); -			let c: Box<u8> = Box::new(7); -			println!("Boxes: {}, {}, {}", a, b, c); -		} -		println!("U8: {:?}", mem::alloc::U8_GRAND_ALLOC); -		{ -			let mut s = String::new(); -			for _ in 0..128 { -				s += "TEST"; -			} -			println!("String: Length {}", s.capacity()); -			let s = format!("{:X}", 0xCAFEBABE as u32); -			println!("String: 0x{}", s); +		let mut s = String::new(); +		for _ in 0..128 { +			s += "TEST";  		} -		use crate::console::interface::Statistics; -		println!("Characters written to UART: \x1b[91m{}\x1b[0m", console().chars_written()); +		assert_eq!(s.capacity(), 512);  	} -	loop { } +	{ +		let s = format!("{:X}", 0xCAFEBABE as u32); +		assert_eq!(s, "CAFEBABE"); +		assert_eq!(s.capacity(), 8); +	} +	{ +		let a: Box<u8> = Box::new(1); +		assert_eq!(*a, 1); +		println!("{}", a); +	} +	{ +		let a: Box<u8> = Box::new(2); +		let b: Box<u8> = Box::new(3); +		let c: Box<u8> = Box::new(4); +		assert_eq!(*a, 2); +		assert_eq!(*b, 3); +		assert_eq!(*c, 4); +		println!("{} {} {}", a, b, c); +	} +	{ +		let a: Box<u8> = Box::new(5); +		let b: Box<u8> = Box::new(6); +		let c: Box<u8> = Box::new(7); +		assert_eq!(*a, 5); +		assert_eq!(*b, 6); +		assert_eq!(*c, 7); +		println!("{} {} {}", a, b, c); +	} +	use crate::console::interface::Statistics; +	println!("Characters written to UART: \x1b[91m{}\x1b[0m", console().chars_written());  } | 
