_add works

This commit is contained in:
Rowan Torbitzky-Lane 2025-04-18 01:24:05 -05:00
parent 2f0500c2d2
commit 9af22c13c6
2 changed files with 4 additions and 18 deletions

View File

@ -13,13 +13,14 @@ use std::ops::{Add, Div, Mul, Sub};
use super::utils::{CastingTrait, NumericTrait};
/// Adds two addable values together.
fn _add<T>(b: T, a: T) -> Option<T>
fn _add<T>(a: T, b: T) -> Option<T>
where
T: Add<Output = T> + Copy,
{
Some(b + a)
}
make_instruction_new!(_add, int, int, int, int);
make_instruction_new!(_add, float, float, float, float);
/// Subtracts two subtractable values from each other.
fn _sub<T>(vals: Vec<T>) -> Option<T>
@ -311,11 +312,8 @@ mod tests {
/// Tests the _add function.
#[test]
fn add_test() {
let vals: Vec<i64> = vec![1, 2];
assert_eq!(Some(3), _add(vals));
let vals: Vec<Decimal> = vec![dec!(1.1), dec!(2.2)];
assert_eq!(Some(dec!(3.3)), _add(vals));
assert_eq!(Some(3), _add(1, 2));
assert_eq!(Some(dec!(3.3)), _add(dec!(1.1), dec!(2.2)));
}
/// Tests the _sub function.

View File

@ -7,18 +7,6 @@ mod push;
fn main() {
// These need to stay so linter doesn't go crazy.
int_instructions();
float_instructions();
string_instructions();
boolean_instructions();
char_instructions();
vector_int_instructions();
vector_float_instructions();
vector_string_instructions();
vector_boolean_instructions();
vector_char_instructions();
exec_instructions();
code_instructions();
let mut empty_state = EMPTY_STATE;
interpret_program(&mut empty_state, 1000, 1000);