Skip to content

Commit

Permalink
added uncat0: conditional trap
Browse files Browse the repository at this point in the history
  • Loading branch information
chyanju committed Jan 24, 2024
1 parent db93092 commit ba08fc1
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 10 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/test/README.md → tests/public/uncat0/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# test.aleo
# uncat0.aleo

## Build Guide

Expand Down
1 change: 1 addition & 0 deletions tests/public/uncat0/inputs/ex0.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0u8
1 change: 1 addition & 0 deletions tests/public/uncat0/inputs/ex1.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0u8
1 change: 1 addition & 0 deletions tests/public/uncat0/inputs/ex2.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
200u8
1 change: 1 addition & 0 deletions tests/public/uncat0/leo.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package = []
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"program": "test.aleo",
"program": "uncat0.aleo",
"version": "0.0.0",
"description": "",
"license": "MIT"
Expand Down
36 changes: 36 additions & 0 deletions tests/public/uncat0/src/main.leo
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// The 'uncat0' program.
program uncat0.aleo {
transition vanguard_helper() -> [bool; 3] {
return [
label_ex0, label_ex1, label_ex2,
];
}

// conditional trap
// compilable, exception at runtime
// label: bad
const label_ex0: bool = true;
transition ex0(a: u8) -> u8 {
if a == 0u8 { return 1u8; }
let c: u8 = 224u8 / a;
return c;
}

// conditional trap
// compilable, exception at runtime
// label: bad
const label_ex1: bool = true;
transition ex1(a: u8) -> u8 {
let c: u8 = a == 0u8 ? 224u8 / 1u8 : 224u8 / a;
return c;
}

// conditional trap
// compilable, exception when a >= 200
// label: bad
const label_ex2: bool = true;
transition ex2(a: u8) -> u8 {
let c: u8 = a >= 200u8 ? a : 56u8 + a;
return c;
}
}
Empty file removed tests/test/imports/helpers.leo
Empty file.
Empty file removed tests/test/leo.lock
Empty file.
8 changes: 0 additions & 8 deletions tests/test/src/main.leo

This file was deleted.

0 comments on commit ba08fc1

Please sign in to comment.