add new external mapping tests

This commit is contained in:
evan-schott 2024-03-29 10:04:34 -07:00
parent 23ad88bdbc
commit 84f0bd6142
10 changed files with 145 additions and 10 deletions

View File

@ -44,7 +44,7 @@ members = [
]
[workspace.dependencies.snarkvm]
version = "0.16.18"
version = "0.16.19"
[lib]
path = "leo/lib.rs"

View File

@ -131,8 +131,6 @@ fn run_test(test: Test, handler: &Handler, buf: &BufferEmitter) -> Result<Value,
let program_name = parsed.program_name.to_string();
let bytecode = handler.extend_if_error(compile_and_process(&mut parsed))?;
dbg!(bytecode.clone());
// Parse the bytecode as an Aleo program.
// Note that this function checks that the bytecode is well-formed.
let aleo_program = handler.extend_if_error(ProgramCore::from_str(&bytecode).map_err(LeoError::Anyhow))?;

View File

@ -37,17 +37,11 @@ impl ParserContext<'_> {
match parsed_program_scope {
// Only one program scope is allowed per file.
true => {
println!("here!!!!\n");
dbg!(self.prev_token.token.clone());
dbg!(self.token.token.clone());
return Err(ParserError::only_one_program_scope_is_allowed(self.token.span).into());
}
false => {
parsed_program_scope = true;
let program_scope = self.parse_program_scope()?;
println!("XXX\n\n");
dbg!(program_scope.program_id.name.name);
println!("XXX\n\n");
program_scopes.insert(program_scope.program_id.name.name, program_scope);
}
}

View File

@ -2,4 +2,4 @@
namespace: Compile
expectation: Fail
outputs:
- "Error [ETYC0372005]: Unknown variable `users`\n --> compiler-test:10:35\n |\n 10 | let a:bool = Mapping::get(relay.aleo/users, addr);\n | ^^^^^^^^^^^^^^^^\n"
- "Error [ETYC0372005]: Unknown variable `users`\n --> compiler-test:11:35\n |\n 11 | let a:bool = Mapping::get(relay.aleo/users, addr);\n | ^^^^^^^^^^^^^^^^\n"

View File

@ -0,0 +1,31 @@
---
namespace: Compile
expectation: Pass
outputs:
- - compile:
- initial_symbol_table: 7451c094e7b88ca46239b92cf776a86dcfe3557d19d9518367be405ea0f0867c
type_checked_symbol_table: 5f381ae8cd5a670b6583e91ceb6ac77f114e8dc14ec5628549022745f7daecca
unrolled_symbol_table: 5f381ae8cd5a670b6583e91ceb6ac77f114e8dc14ec5628549022745f7daecca
initial_ast: 86e48730f8e92400fd88dba80ab0f127d9482d4fc77e6ef90f71b41c0abc172f
unrolled_ast: 86e48730f8e92400fd88dba80ab0f127d9482d4fc77e6ef90f71b41c0abc172f
ssa_ast: fe92668a4538356db262e3130c9776e9e59278775ca85a14e9774eff4513f20e
flattened_ast: 2fcb45d35ed01007903369762d4f6c66c7265c8037a667b0605930e97f5d1164
destructured_ast: e45cbf7845145504575074babe9704bdbf0531ea7407c261a15c34a5fa1885f4
inlined_ast: e45cbf7845145504575074babe9704bdbf0531ea7407c261a15c34a5fa1885f4
dce_ast: e45cbf7845145504575074babe9704bdbf0531ea7407c261a15c34a5fa1885f4
bytecode: c44dd5a8d2158e3729310c6e423739cde6f4f8261609820886f26aa09afe707b
errors: ""
warnings: ""
- initial_symbol_table: f1bdf4ae2702708d6d85ba318ad8ff9808124a83f107a19b15f4d30e167e6d11
type_checked_symbol_table: d687b1f3c123bda116691c0b5a1b9a1895f20fa0d88511473a0881fe749ef9b7
unrolled_symbol_table: d687b1f3c123bda116691c0b5a1b9a1895f20fa0d88511473a0881fe749ef9b7
initial_ast: f4f8e8eb75a9ae12e391ee4107b0fd10a2013e768d1ecb742b636b554baf7ae6
unrolled_ast: 365df4c78ec80b1018c3916d6c6c5f166a973ec95f6312b2215e3aa44b6dfef9
ssa_ast: 94499ab484cb507a2a09279e4adbeea903a418ef516cb0a13fadf41e26482a3b
flattened_ast: 41167a9098ff4dcdb91390effc77000faa121a41cd1f4d056f994c8a09f80c28
destructured_ast: 604f5ded275781d99f1b6bcc7443a8b1cadb30c8cce0ccc8abf66b7acc77fc6d
inlined_ast: 604f5ded275781d99f1b6bcc7443a8b1cadb30c8cce0ccc8abf66b7acc77fc6d
dce_ast: 604f5ded275781d99f1b6bcc7443a8b1cadb30c8cce0ccc8abf66b7acc77fc6d
bytecode: 1260b31fff8f93549822bd3a3bba846b38ca6dd13eacaf908842384748b4ea4c
errors: ""
warnings: ""

View File

@ -0,0 +1,5 @@
---
namespace: Compile
expectation: Fail
outputs:
- "Error [ETYC0372005]: Unknown variable `foo`\n --> compiler-test:9:35\n |\n 9 | let a:bool = Mapping::get(registry.aleo/foo, addr);\n | ^^^^^^^^^^^^^^^^^\n"

View File

@ -15,6 +15,7 @@ program registry.aleo {
}
// --- Next Program --- //
import registry.aleo;
program relay.aleo {
mapping users: address => bool;

View File

@ -0,0 +1,28 @@
/*
namespace: Compile
expectation: Fail
*/
program registry.aleo {
mapping users: address => bool;
transition register() {
return then finalize(self.caller);
}
finalize register(addr: address) {
Mapping::set(users, addr, true);
}
}
// --- Next Program --- //
program relay.aleo {
transition send(addr: address) {
return then finalize(addr);
}
finalize send(addr: address) {
let a:bool = Mapping::get(registry.aleo/users, addr);
assert_eq(a, true);
}
}

View File

@ -0,0 +1,49 @@
/*
namespace: Compile
expectation: Pass
*/
program registry.aleo {
mapping users: address => bool;
transition register() {
return then finalize(self.caller);
}
finalize register(addr: address) {
Mapping::set(users, addr, true);
}
transition unregister() {
return then finalize(self.caller);
}
finalize unregister(addr: address) {
Mapping::set(users, addr, false);
}
}
// --- Next Program --- //
import registry.aleo;
program relay.aleo {
mapping users: address => bool;
record message {
owner: address;
data: u8;
}
transition send(addr: address, val: u8) -> message {
return message {owner: addr, data: val} then finalize(addr);
}
finalize send(addr: address) {
let a:bool = Mapping::get(registry.aleo/users, addr);
assert_eq(a, true);
}
transition send_without_check(addr: address, val: u8) -> message {
return message {owner: addr, data: val} then finalize(addr);
}
finalize send_without_check(addr: address) {
let a:bool = Mapping::get_or_use(registry.aleo/users, addr, true);
assert_eq(a, true);
}
}

View File

@ -0,0 +1,29 @@
/*
namespace: Compile
expectation: Fail
*/
program registry.aleo {
mapping users: address => bool;
transition register() {
return then finalize(self.caller);
}
finalize register(addr: address) {
Mapping::set(users, addr, true);
}
}
// --- Next Program --- //
import registry.aleo;
program relay.aleo {
transition send(addr: address) {
return then finalize(addr);
}
finalize send(addr: address) {
let a:bool = Mapping::get(registry.aleo/foo, addr);
assert_eq(a, true);
}
}