WARNING! Access to this system is limited to authorised users only.
Unauthorised users may be subject to prosecution.
Unauthorised access to this system is a criminal offence under Australian law (Federal Crimes Act 1914 Part VIA)
It is a criminal offence to:
(1) Obtain access to data without authority. -Penalty 2 years imprisonment.
(2) Damage, delete, alter or insert data without authority. -Penalty 10 years imprisonment.
User activity is monitored and recorded. Anyone using this system expressly consents to such monitoring and recording.

To protect your data, the CISO officer has suggested users to enable 2FA as soon as possible.
Currently 2.7% of users enabled 2FA.

test_compiler.rs 657 Bytes
Newer Older
John Zhang's avatar
John Zhang committed
1
extern crate libloading as ll;
2
extern crate mu;
3
4
5

use test_ir::test_ir::sum;
use test_ir::test_ir::factorial;
6
use mu::testutil;
7
8

#[test]
John Zhang's avatar
John Zhang committed
9
10
fn test_factorial() {
    let lib = testutil::compile_fnc("fac", &factorial);
11
    unsafe {
John Zhang's avatar
John Zhang committed
12
13
14
        let fac: ll::Symbol<unsafe extern fn (u64) -> u64> = lib.get(b"fac").unwrap();
        println!("fac(10) = {}", fac(10));
        assert!(fac(10) == 3628800);
15
16
17
18
    }
}

#[test]
John Zhang's avatar
John Zhang committed
19
20
fn test_sum() {
    let lib = testutil::compile_fnc("sum", &sum);
21
    unsafe {
John Zhang's avatar
John Zhang committed
22
23
24
25
26
        let sumptr: ll::Symbol<unsafe extern fn (u64) -> u64> = lib.get(b"sum").unwrap();
        assert!(sumptr(5) == 10);
        assert!(sumptr(10) == 45);
    }
}