diff --git a/crates/aiken-lang/src/tests/format.rs b/crates/aiken-lang/src/tests/format.rs
index acd19f4a..f37aa2cb 100644
--- a/crates/aiken-lang/src/tests/format.rs
+++ b/crates/aiken-lang/src/tests/format.rs
@@ -2,23 +2,28 @@ use crate::assert_format;
#[test]
fn test_format_comment_at_end_of_file() {
- assert_format!(r#"
+ assert_format!(
+ r#"
type Foo =
Int
- //"#);
+ //"#
+ );
}
#[test]
fn test_format_simple_module() {
- assert_format!(r#"
+ assert_format!(
+ r#"
fn smth() { let a = foo.Foo { bar: 1 } }
- "#);
+ "#
+ );
}
#[test]
fn test_format_if() {
- assert_format!(r#"
+ assert_format!(
+ r#"
pub fn foo(a) {
if a { 14 } else { 42 }
}
@@ -26,12 +31,14 @@ fn test_format_if() {
pub fn bar(xs) {
list.map(xs, fn (x) { if x > 0 { "foo" } else { "bar" } })
}
- "#);
+ "#
+ );
}
#[test]
fn test_format_validator() {
- assert_format!(r#"
+ assert_format!(
+ r#"
validator ( ) {
// What is the purpose of life
@@ -49,12 +56,14 @@ fn test_format_validator() {
// I am lost
}
- "#);
+ "#
+ );
}
#[test]
fn test_format_double_validator() {
- assert_format!(r#"
+ assert_format!(
+ r#"
validator ( param1 : ByteArray ) {
fn foo (d: Datum, r: Redeemer, ctx: ScriptContext) -> Bool {
True
@@ -62,12 +71,14 @@ fn test_format_double_validator() {
/// This is bar
fn bar(r: Redeemer, ctx : ScriptContext ) -> Bool { True }
}
- "#);
+ "#
+ );
}
#[test]
fn test_format_when() {
- assert_format!(r#"
+ assert_format!(
+ r#"
pub fn foo( a) {
when a is{
True -> {
@@ -83,12 +94,14 @@ fn test_format_when() {
}
}
- "#);
+ "#
+ );
}
#[test]
fn test_format_nested_if() {
- assert_format!(r#"
+ assert_format!(
+ r#"
pub fn foo(n) {
if n > 0 {
if n > 1 { if n > 2 { "foo" } else { "foo" } } else { "bar" }
@@ -96,12 +109,14 @@ fn test_format_nested_if() {
if n < -1 { "baz" } else { "biz" }
}
}
- "#);
+ "#
+ );
}
#[test]
fn test_format_nested_when_if() {
- assert_format!(r#"
+ assert_format!(
+ r#"
pub fn drop(xs: List, n: Int) -> List {
if n <= 0 {
xs
@@ -114,12 +129,14 @@ fn test_format_nested_when_if() {
}
}
}
- "#);
+ "#
+ );
}
#[test]
fn test_format_nested_when() {
- assert_format!(r#"
+ assert_format!(
+ r#"
fn foo() {
when a is {
None -> "foo"
@@ -132,12 +149,14 @@ fn test_format_nested_when() {
}
}
}
- "#);
+ "#
+ );
}
#[test]
fn test_format_else_if() {
- assert_format!(r#"
+ assert_format!(
+ r#"
pub fn foo(xs: List, n: Int) -> List {
if n <= 0 {
xs
@@ -147,14 +166,16 @@ fn test_format_else_if() {
xs
}
}
- "#);
+ "#
+ );
}
#[test]
fn test_format_imports() {
// TODO: Fix this case, this is behaving weirdly, not keeping the order for the comments and
// imports.
- assert_format!(r#"
+ assert_format!(
+ r#"
use aiken/list
// foo
use aiken/bytearray
@@ -162,21 +183,25 @@ fn test_format_imports() {
// bar
use aiken/transaction
use aiken/transaction/value
- "#);
+ "#
+ );
}
#[test]
fn test_format_negate() {
- assert_format!(r#"
+ assert_format!(
+ r#"
fn foo() {
- 42
}
- "#);
+ "#
+ );
}
#[test]
fn test_format_block_arithmetic_expr() {
- assert_format!(r#"
+ assert_format!(
+ r#"
fn foo() {
( 14 + 42 ) * 1337
}
@@ -184,12 +209,14 @@ fn test_format_block_arithmetic_expr() {
fn bar() {
{ 14 + 42 } * 1337
}
- "#);
+ "#
+ );
}
#[test]
fn test_format_block_logical_expr() {
- assert_format!(r#"
+ assert_format!(
+ r#"
fn foo() {
!(a && b)
}
@@ -201,12 +228,14 @@ fn test_format_block_logical_expr() {
fn baz() {
a || (b && c) || d
}
- "#);
+ "#
+ );
}
#[test]
fn test_format_nested_function_calls() {
- assert_format!(r#"
+ assert_format!(
+ r#"
fn foo(output) {
[
output.address.stake_credential == Some(
@@ -223,12 +252,14 @@ fn test_format_nested_function_calls() {
]
|> list.and
}
- "#);
+ "#
+ );
}
#[test]
fn test_format_trace_todo_error() {
- assert_format!(r#"
+ assert_format!(
+ r#"
fn foo_1() {
todo
}
@@ -252,12 +283,14 @@ fn test_format_trace_todo_error() {
True
}
}
- "#);
+ "#
+ );
}
#[test]
fn test_format_trace_if_false() {
- assert_format!(r#"
+ assert_format!(
+ r#"
fn foo() {
my_expression?
}
@@ -265,12 +298,14 @@ fn test_format_trace_if_false() {
fn bar() {
(True && False)? || foo()?
}
- "#);
+ "#
+ );
}
#[test]
fn test_format_newline_comments() {
- assert_format!(r#"
+ assert_format!(
+ r#"
// My comment
//
// has a newline.
@@ -284,12 +319,14 @@ fn test_format_newline_comments() {
fn bar() {
True
}
- "#);
+ "#
+ );
}
#[test]
fn test_format_newline_doc_comments() {
- assert_format!(r#"
+ assert_format!(
+ r#"
/// My doc comment
///
/// has a newline.
@@ -303,12 +340,14 @@ fn test_format_newline_doc_comments() {
fn bar() {
True
}
- "#);
+ "#
+ );
}
#[test]
fn test_format_newline_module_comments() {
- assert_format!(r#"
+ assert_format!(
+ r#"
//// My module comment
////
//// has a newline.
@@ -320,12 +359,14 @@ fn test_format_newline_module_comments() {
//// My module comments
//// cannot be separated
- "#);
+ "#
+ );
}
#[test]
fn test_format_bytearray_literals() {
- assert_format!(r#"
+ assert_format!(
+ r#"
const foo_const_array = #[102, 111, 111]
const foo_const_hex = #"666f6f"
@@ -339,34 +380,40 @@ fn test_format_bytearray_literals() {
let foo_const_utf8 = "foo"
}
- "#);
+ "#
+ );
}
#[test]
fn test_format_string_literal() {
- assert_format!(r#"
+ assert_format!(
+ r#"
const foo_const: String = @"foo"
fn foo() {
let foo_var: String = @"foo"
}
- "#);
+ "#
+ );
}
#[test]
fn test_format_unicode() {
- assert_format!(r#"
+ assert_format!(
+ r#"
/// ∞ ★ ♩ ♫ ✓
fn foo() {
trace @"∀💩"
Void
}
- "#);
+ "#
+ );
}
#[test]
fn test_format_preserve_pipe() {
- assert_format!(r#"
+ assert_format!(
+ r#"
fn foo() {
a |> b |> c |> d
}
@@ -383,12 +430,14 @@ fn test_format_preserve_pipe() {
// Commented
however |> it_automatically_breaks |> into_multiple_lines |> anytime_when |> it_is_too_long // What?
}
- "#);
+ "#
+ );
}
#[test]
fn test_format_weird_comments() {
- assert_format!(r#"
+ assert_format!(
+ r#"
// A
/// B
@@ -406,35 +455,41 @@ fn test_format_weird_comments() {
fn bar() {
todo
}
- "#);
+ "#
+ );
}
#[test]
fn test_format_trace_callback() {
- assert_format!(r#"
+ assert_format!(
+ r#"
fn foo() {
list.any([], fn (e) { trace @"foo"
e
})
}
- "#);
+ "#
+ );
}
#[test]
fn test_format_pipe_fn() {
- assert_format!(r#"
+ assert_format!(
+ r#"
fn foo() {
outputs
|> list.any(
fn(output) { value.quantity_of(output.value, policy_id, asset_name) == 1 },
)
}
- "#);
+ "#
+ );
}
#[test]
fn test_format_match_record() {
- assert_format!(r#"
+ assert_format!(
+ r#"
fn foo() {
when bar is {
Bar { a, b, c } -> Void
@@ -444,44 +499,52 @@ fn test_format_match_record() {
Bar(..) -> Void
}
}
- "#);
+ "#
+ );
}
#[test]
fn test_format_fail() {
- assert_format!(r#"
+ assert_format!(
+ r#"
!test foo() {
expect Some(a) = bar
a
}
- "#);
+ "#
+ );
}
#[test]
fn test_format_pipes_and_expressions() {
- assert_format!(r#"
+ assert_format!(
+ r#"
test fmt() {
(x == y) && ((z |> length()) == x)
}
- "#);
+ "#
+ );
}
#[test]
fn test_format_hex_and_numeric_underscore() {
- assert_format!(r#"
+ assert_format!(
+ r#"
fn foo() {
let a = 1_000_000 + 1_423 + 10393841
let b = 0xa4 - 0xcd
let c = #[0xfd, 0x12, 0x00, 0x1b, 0x0a, 0x90]
let d = -100_000
}
- "#);
+ "#
+ );
}
#[test]
fn test_format_first_class_binop() {
- assert_format!(r#"
+ assert_format!(
+ r#"
fn foo() {
compare_with(a, >, b)
compare_with(a, >=, b)
@@ -497,12 +560,14 @@ fn test_format_first_class_binop() {
compute_with(a, *, b)
compute_with(a, %, b)
}
- "#);
+ "#
+ );
}
#[test]
fn test_format_int_uint() {
- assert_format!(r#"
+ assert_format!(
+ r#"
const i = 42
const j = -14
@@ -513,5 +578,6 @@ fn test_format_int_uint() {
-42 -> 42
}
}
- "#);
+ "#
+ );
}