-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement
to_be_radix
in the comptime interpreter (#6043)
# Description ## Problem\* Resolves #6042 ## Summary\* This PR implements `to_be_radix` in the comptime interpreter by reusing our impl for `to_le_radix`. ## Additional Context ## Documentation\* Check one: - [x] No documentation needed. - [ ] Documentation included in this PR. - [ ] **[For Experimental Features]** Documentation to be submitted in a separate PR. # PR Checklist\* - [x] I have tested the changes locally. - [x] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings.
- Loading branch information
1 parent
b3accfc
commit 1550278
Showing
3 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
test_programs/compile_success_empty/comptime_to_radix/Nargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[package] | ||
name = "comptime_to_radix" | ||
type = "bin" | ||
authors = [""] | ||
|
||
[dependencies] |
10 changes: 10 additions & 0 deletions
10
test_programs/compile_success_empty/comptime_to_radix/src/main.nr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
fn main() { | ||
comptime | ||
{ | ||
let le_bytes: [u8; 3] = 257.to_le_bytes(); | ||
assert_eq(le_bytes, [1, 1, 0]); | ||
|
||
let be_bytes: [u8; 3] = 257.to_be_bytes(); | ||
assert_eq(be_bytes, [0, 1, 1]); | ||
} | ||
} |