Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,13 @@ This repository contains the standard library for [SimplicityHL](https://github.
> If you are using the VS Code syntax highlighting extension, you may see errors because the extension does not support modules and imports yet.
## Dev Info

### Installation

> Project currently uses Simplex version 0.0.6 from the dev branch.
To compile the project, execute the following command:

```bash
cargo build
```

To download simplexup, run:

```bash
Expand Down Expand Up @@ -62,6 +59,12 @@ To run a specific test:
simplex test test_name
```

To run a specific test module:

```bash
simplex test u8_test
```

### Linting

To format the rust files, execute the following command:
Expand Down
102 changes: 0 additions & 102 deletions simf/asserts_mock.simf

This file was deleted.

40 changes: 40 additions & 0 deletions simf/asserts_test.simf
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
use crate::lib::asserts::{assert_eq_8, assert_eq_16, assert_eq_32, assert_eq_64, assert_eq_256, assert_none_8, assert_none_16, assert_none_32, assert_none_64,assert_none_128, assert_none_256};

use crate::helper::if_test_this_function;

fn main() {
let fn_idx: u8 = witness::FUNCTION_INDEX;

let a_u8: Option<u8> = witness::FIRST_ARG_U8;
let b_u8: Option<u8> = witness::SECOND_ARG_U8;

let a_u16: Option<u16> = witness::FIRST_ARG_U16;
let b_u16: Option<u16> = witness::SECOND_ARG_U16;

let a_u32: Option<u32> = witness::FIRST_ARG_U32;
let b_u32: Option<u32> = witness::SECOND_ARG_U32;

let a_u64: Option<u64> = witness::FIRST_ARG_U64;
let b_u64: Option<u64> = witness::SECOND_ARG_U64;

let a_u128: Option<u128> = witness::FIRST_ARG_U128;
let b_u128: Option<u128> = witness::SECOND_ARG_U128;

let a_u256: Option<u256> = witness::FIRST_ARG_U256;
let b_u256: Option<u256> = witness::SECOND_ARG_U256;

// Assert Eq
match if_test_this_function(0, fn_idx) { true => { assert_eq_8(unwrap(a_u8), unwrap(b_u8)); }, false => (), };
match if_test_this_function(1, fn_idx) { true => { assert_eq_16(unwrap(a_u16), unwrap(b_u16)); }, false => (), };
match if_test_this_function(2, fn_idx) { true => { assert_eq_32(unwrap(a_u32), unwrap(b_u32)); }, false => (), };
match if_test_this_function(3, fn_idx) { true => { assert_eq_64(unwrap(a_u64), unwrap(b_u64)); }, false => (), };
match if_test_this_function(4, fn_idx) { true => { assert_eq_256(unwrap(a_u256), unwrap(b_u256)); }, false => (), };

// Assert None
match if_test_this_function(5, fn_idx) { true => { assert_none_8(a_u8); }, false => (), };
match if_test_this_function(6, fn_idx) { true => { assert_none_16(a_u16); }, false => (), };
match if_test_this_function(7, fn_idx) { true => { assert_none_32(a_u32); }, false => (), };
match if_test_this_function(8, fn_idx) { true => { assert_none_64(a_u64); }, false => (), };
match if_test_this_function(9, fn_idx) { true => { assert_none_128(a_u128); }, false => (), };
match if_test_this_function(10, fn_idx) { true => { assert_none_256(a_u256); }, false => (), };
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::lib::logical_operations::{not, or, and};

fn main() {
assert!(not(false));
assert!(not((not(true))));
assert!(not(not(true)));

assert!(or(true, false));
assert!(or(false, true));
Expand Down
140 changes: 0 additions & 140 deletions simf/u16_mock.simf

This file was deleted.

37 changes: 37 additions & 0 deletions simf/u16_test.simf
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
use crate::lib::u16::{checked_add_16, safe_add_16, checked_sub_16, safe_sub_16, checked_mul_16, safe_mul_16, checked_div_16, safe_div_16};

use crate::helper::if_test_this_function;

// Asserts a `checked_*` result equals the expected Option.
// `None` encodes the overflow case, `Some(e)` the fitting case, so a single
// witness value carries both, removing the need for a separate overflow flag.
fn assert_eq_opt(result: Option<u16>, expected: Option<u16>) {
match expected {
None => assert!(is_none::<u16>(result)),
Some(e: u16) => assert!(jet::eq_16(unwrap(result), e)),
}
}

fn main() {
let fn_idx: u8 = witness::FUNCTION_INDEX;

let a: u16 = witness::FIRST_ARG;
let b: u16 = witness::SECOND_ARG;
let expected: Option<u16> = witness::EXPECTED;

// add
match if_test_this_function(0, fn_idx) { true => { assert_eq_opt(checked_add_16(a, b), expected); }, false => (), };
match if_test_this_function(1, fn_idx) { true => { assert!(jet::eq_16(safe_add_16(a, b), unwrap(expected))); }, false => (), };

// sub
match if_test_this_function(2, fn_idx) { true => { assert_eq_opt(checked_sub_16(a, b), expected); }, false => (), };
match if_test_this_function(3, fn_idx) { true => { assert!(jet::eq_16(safe_sub_16(a, b), unwrap(expected))); }, false => (), };

// mul
match if_test_this_function(4, fn_idx) { true => { assert_eq_opt(checked_mul_16(a, b), expected); }, false => (), };
match if_test_this_function(5, fn_idx) { true => { assert!(jet::eq_16(safe_mul_16(a, b), unwrap(expected))); }, false => (), };

// div
match if_test_this_function(6, fn_idx) { true => { assert_eq_opt(checked_div_16(a, b), expected); }, false => (), };
match if_test_this_function(7, fn_idx) { true => { assert!(jet::eq_16(safe_div_16(a, b), unwrap(expected))); }, false => (), };
}
Loading