1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Copyright (c) 2021 Saadi Save
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

#![deny(clippy::pedantic)]
#![allow(
    clippy::missing_errors_doc,
    clippy::missing_panics_doc,
    clippy::must_use_candidate,
    clippy::items_after_test_module
)]
#![cfg_attr(docsrs, feature(doc_auto_cfg, doc_cfg))]

#[macro_use]
extern crate log;

pub mod exec;
pub mod inst;
pub mod parse;

#[cfg(feature = "compile")]
pub mod compile;

#[cfg(test)]
pub(crate) mod test_stdio {
    include!("../test_stdio.rs");
}

#[cfg(test)]
pub(crate) use test_stdio::TestStdio;

#[cfg(test)]
#[cfg(not(feature = "extended"))]
const PROGRAMS: [(&str, usize, &[u8], &[u8]); 1] =
    [(include_str!("../examples/hello.pasm"), 207, b"", b"HELLO\n")];

#[cfg(test)]
#[cfg(feature = "extended")]
const PROGRAMS: [(&str, usize, &[u8], &[u8]); 5] = [
    (
        include_str!("../examples/division.pasm"),
        65,
        b"",
        b"5\nA\n",
    ),
    (
        include_str!("../examples/multiplication.pasm"),
        15625,
        b"",
        b"15625\n",
    ),
    (include_str!("../examples/hello.pasm"), 207, b"", b"HELLO\n"),
    (include_str!("../examples/functions.pasm"), 65, b"", b"A"),
    (
        include_str!("../examples/showoff.pasm"),
        68,
        b"DIANA",
        b"HELLO\n",
    ),
];