Skip to main content

cambridge_asm/
lib.rs

1// Copyright (c) 2021 Saadi Save
2// This Source Code Form is subject to the terms of the Mozilla Public
3// License, v. 2.0. If a copy of the MPL was not distributed with this
4// file, You can obtain one at http://mozilla.org/MPL/2.0/.
5
6#![deny(clippy::pedantic)]
7#![allow(
8    clippy::missing_errors_doc,
9    clippy::missing_panics_doc,
10    clippy::must_use_candidate,
11    clippy::items_after_test_module
12)]
13#![cfg_attr(docsrs, feature(doc_cfg))]
14
15#[macro_use]
16extern crate log;
17
18pub mod exec;
19pub mod inst;
20pub mod parse;
21
22#[cfg(feature = "compile")]
23pub mod compile;
24
25#[cfg(test)]
26pub(crate) mod test_stdio {
27    include!("../test_stdio.rs");
28}
29
30#[cfg(test)]
31pub(crate) use test_stdio::TestStdio;
32
33#[cfg(test)]
34#[cfg(not(feature = "extended"))]
35const PROGRAMS: [(&str, usize, &[u8], &[u8]); 1] =
36    [(include_str!("../examples/hello.pasm"), 207, b"", b"HELLO\n")];
37
38#[cfg(test)]
39#[cfg(feature = "extended")]
40const PROGRAMS: [(&str, usize, &[u8], &[u8]); 5] = [
41    (
42        include_str!("../examples/division.pasm"),
43        65,
44        b"",
45        b"5\nA\n",
46    ),
47    (
48        include_str!("../examples/multiplication.pasm"),
49        15625,
50        b"",
51        b"15625\n",
52    ),
53    (include_str!("../examples/hello.pasm"), 207, b"", b"HELLO\n"),
54    (include_str!("../examples/functions.pasm"), 65, b"", b"A"),
55    (
56        include_str!("../examples/showoff.pasm"),
57        68,
58        b"DIANA",
59        b"HELLO\nDIANA\n",
60    ),
61];