2020-07-02 15:48:43 +03:00
|
|
|
use crate::{integers::u32::output_one, parse_program};
|
2020-05-21 01:51:57 +03:00
|
|
|
|
2020-06-27 03:12:04 +03:00
|
|
|
use std::env::{current_dir, set_current_dir};
|
|
|
|
|
|
|
|
static TEST_SOURCE_DIRECTORY: &str = "tests/import";
|
|
|
|
|
2020-06-09 05:31:29 +03:00
|
|
|
// Import tests rely on knowledge of local directories. They should be run locally only.
|
|
|
|
|
2020-06-27 03:12:04 +03:00
|
|
|
fn set_local_dir() {
|
|
|
|
let mut local = current_dir().unwrap();
|
|
|
|
local.push(TEST_SOURCE_DIRECTORY);
|
|
|
|
|
|
|
|
set_current_dir(local).unwrap();
|
|
|
|
}
|
|
|
|
|
2020-05-21 01:51:57 +03:00
|
|
|
#[test]
|
2020-06-09 05:31:29 +03:00
|
|
|
#[ignore]
|
2020-05-21 01:51:57 +03:00
|
|
|
fn test_basic() {
|
2020-07-02 15:48:43 +03:00
|
|
|
set_local_dir();
|
|
|
|
|
2020-06-09 04:52:35 +03:00
|
|
|
let bytes = include_bytes!("basic.leo");
|
|
|
|
let program = parse_program(bytes).unwrap();
|
|
|
|
|
2020-05-21 01:51:57 +03:00
|
|
|
output_one(program);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2020-06-09 05:31:29 +03:00
|
|
|
#[ignore]
|
2020-05-21 01:51:57 +03:00
|
|
|
fn test_multiple() {
|
2020-07-02 15:48:43 +03:00
|
|
|
set_local_dir();
|
|
|
|
|
2020-06-09 04:52:35 +03:00
|
|
|
let bytes = include_bytes!("multiple.leo");
|
|
|
|
let program = parse_program(bytes).unwrap();
|
|
|
|
|
2020-05-21 01:51:57 +03:00
|
|
|
output_one(program);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2020-06-09 05:31:29 +03:00
|
|
|
#[ignore]
|
2020-05-21 01:51:57 +03:00
|
|
|
fn test_star() {
|
2020-07-02 15:48:43 +03:00
|
|
|
set_local_dir();
|
|
|
|
|
2020-06-09 04:52:35 +03:00
|
|
|
let bytes = include_bytes!("star.leo");
|
|
|
|
let program = parse_program(bytes).unwrap();
|
|
|
|
|
2020-05-21 01:51:57 +03:00
|
|
|
output_one(program);
|
|
|
|
}
|
|
|
|
|
2020-06-30 23:31:27 +03:00
|
|
|
#[test]
|
|
|
|
#[ignore]
|
|
|
|
fn test_star_fail() {
|
|
|
|
set_local_dir();
|
|
|
|
|
2020-07-02 15:48:43 +03:00
|
|
|
let bytes = include_bytes!("star_fail.leo");
|
|
|
|
assert!(parse_program(bytes).is_err());
|
2020-06-30 23:31:27 +03:00
|
|
|
}
|
|
|
|
|
2020-05-21 01:51:57 +03:00
|
|
|
#[test]
|
2020-06-09 05:31:29 +03:00
|
|
|
#[ignore]
|
2020-05-21 01:51:57 +03:00
|
|
|
fn test_alias() {
|
2020-07-02 15:48:43 +03:00
|
|
|
set_local_dir();
|
|
|
|
|
2020-06-09 04:52:35 +03:00
|
|
|
let bytes = include_bytes!("alias.leo");
|
|
|
|
let program = parse_program(bytes).unwrap();
|
|
|
|
|
2020-05-21 01:51:57 +03:00
|
|
|
output_one(program);
|
|
|
|
}
|
2020-06-30 03:47:23 +03:00
|
|
|
|
|
|
|
// more complex tests
|
|
|
|
#[test]
|
|
|
|
#[ignore]
|
|
|
|
fn test_many_import() {
|
2020-07-02 15:48:43 +03:00
|
|
|
set_local_dir();
|
|
|
|
|
2020-06-30 03:47:23 +03:00
|
|
|
let bytes = include_bytes!("many_import.leo");
|
|
|
|
let program = parse_program(bytes).unwrap();
|
|
|
|
|
|
|
|
output_one(program);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2020-07-02 07:05:57 +03:00
|
|
|
#[ignore]
|
2020-06-30 03:47:23 +03:00
|
|
|
fn test_many_import_star() {
|
2020-07-02 15:48:43 +03:00
|
|
|
set_local_dir();
|
|
|
|
|
2020-06-30 03:47:23 +03:00
|
|
|
let bytes = include_bytes!("many_import_star.leo");
|
|
|
|
let program = parse_program(bytes).unwrap();
|
|
|
|
|
|
|
|
output_one(program);
|
|
|
|
}
|