chore: fmt most of the acceptance tests

This commit is contained in:
rvcas 2023-02-09 00:57:14 -05:00
parent 3f540c7c99
commit 6f591c633d
No known key found for this signature in database
GPG Key ID: C09B64E263F7D68C
13 changed files with 61 additions and 39 deletions

View File

@ -5,17 +5,17 @@ pub fn is_empty(bytes: ByteArray) -> Bool {
} }
test is_empty_1() { test is_empty_1() {
is_empty(#[]) == True is_empty(#"") == True
} }
test is_empty_1_alt() { test is_empty_1_alt() {
is_empty(#[]) is_empty(#"")
} }
test is_empty_2() { test is_empty_2() {
is_empty(#[1]) == False is_empty(#"01") == False
} }
test is_empty_2_alt() { test is_empty_2_alt() {
!is_empty(#[1]) !is_empty(#"01")
} }

View File

@ -5,5 +5,5 @@ pub fn is_empty(bytes: ByteArray) -> Bool {
} }
test is_empty_1() { test is_empty_1() {
is_empty(#[]) == True is_empty(#"") == True
} }

View File

@ -13,6 +13,6 @@ pub fn drop(bytes: ByteArray, n: Int) -> ByteArray {
} }
test drop_1() { test drop_1() {
let x = #[1, 2, 3, 4, 5, 6, 7] let x = #"01020304050607"
drop(x, 2) == #[3, 4, 5, 6, 7] drop(x, 2) == #"0304050607"
} }

View File

@ -9,5 +9,5 @@ pub fn take(bytes: ByteArray, n: Int) -> ByteArray {
} }
test take_1() { test take_1() {
take(#[1, 2, 3], 2) == #[1, 2] take(#"010203", 2) == #"0102"
} }

View File

@ -18,11 +18,7 @@ pub fn insert(
AssocList { inner: do_insert(m.inner, k, v) } AssocList { inner: do_insert(m.inner, k, v) }
} }
fn do_insert( fn do_insert(elems: List<(key, value)>, k: key, v: value) -> List<(key, value)> {
elems: List<(key, value)>,
k: key,
v: value,
) -> List<(key, value)> {
when elems is { when elems is {
[] -> [(k, v)] [] -> [(k, v)]
[(k2, v2), ..rest] -> [(k2, v2), ..rest] ->

View File

@ -25,11 +25,7 @@ pub fn insert(
AssocList { inner: do_insert(m.inner, k, v) } AssocList { inner: do_insert(m.inner, k, v) }
} }
fn do_insert( fn do_insert(elems: List<(key, value)>, k: key, v: value) -> List<(key, value)> {
elems: List<(key, value)>,
k: key,
v: value,
) -> List<(key, value)> {
when elems is { when elems is {
[] -> [(k, v)] [] -> [(k, v)]
[(k2, v2), ..rest] -> [(k2, v2), ..rest] ->

View File

@ -22,7 +22,7 @@ pub fn from_asset(
} }
pub fn from_lovelace(quantity: Int) -> Value { pub fn from_lovelace(quantity: Int) -> Value {
from_asset(#[], #[], quantity) from_asset(#"", #"", quantity)
} }
pub fn add(left v0: Value, right v1: Value) -> Value { pub fn add(left v0: Value, right v1: Value) -> Value {

View File

@ -3,7 +3,7 @@ use aiken/list
use aiken/transaction.{Output, ScriptContext} use aiken/transaction.{Output, ScriptContext}
use aiken/transaction/value.{PolicyId} use aiken/transaction/value.{PolicyId}
const my_policy_id: PolicyId = #[0, 0, 0, 0, 0] const my_policy_id: PolicyId = #"0000000000"
pub fn has_policy_id(self: Output, policy_id: PolicyId) -> Bool { pub fn has_policy_id(self: Output, policy_id: PolicyId) -> Bool {
self.value self.value

View File

@ -37,52 +37,52 @@ pub fn update_door_locked_and_wheels(
test update_owner1() { test update_owner1() {
let initial_car = let initial_car =
Car { Car {
owner: #[], owner: #"",
wheels: 4, wheels: 4,
vin: #[1, 1, 1, 1, 1, 1, 1], vin: #"01010101010101",
door: Door { locked: False, hinge_angle: 45 }, door: Door { locked: False, hinge_angle: 45 },
} }
let final_car = let final_car =
Car { Car {
owner: #[244, 244, 244, 244], owner: #"f4f4f4f4",
wheels: 4, wheels: 4,
vin: #[1, 1, 1, 1, 1, 1, 1], vin: #"01010101010101",
door: Door { locked: False, hinge_angle: 45 }, door: Door { locked: False, hinge_angle: 45 },
} }
update_owner(#[244, 244, 244, 244], initial_car) == final_car update_owner(#"f4f4f4f4", initial_car) == final_car
} }
test update_vin1() { test update_vin1() {
let initial_car = let initial_car =
Car { Car {
owner: #[], owner: #"",
wheels: 4, wheels: 4,
vin: #[1, 1, 1, 1, 1, 1, 1], vin: #"01010101010101",
door: Door { locked: False, hinge_angle: 45 }, door: Door { locked: False, hinge_angle: 45 },
} }
let final_car = let final_car =
Car { Car {
owner: #[], owner: #"",
wheels: 4, wheels: 4,
vin: #[2, 2, 2, 2, 2, 2, 2, 2, 2], vin: #"020202020202020202",
door: Door { locked: False, hinge_angle: 45 }, door: Door { locked: False, hinge_angle: 45 },
} }
update_vin(#[2, 2, 2, 2, 2, 2, 2, 2, 2], initial_car) == final_car update_vin(#"020202020202020202", initial_car) == final_car
} }
test update_door_angle1() { test update_door_angle1() {
let initial_car = let initial_car =
Car { Car {
owner: #[], owner: #"",
wheels: 4, wheels: 4,
vin: #[1, 1, 1, 1, 1, 1, 1], vin: #"01010101010101",
door: Door { locked: False, hinge_angle: 45 }, door: Door { locked: False, hinge_angle: 45 },
} }
let final_car = let final_car =
Car { Car {
owner: #[], owner: #"",
wheels: 4, wheels: 4,
vin: #[1, 1, 1, 1, 1, 1, 1], vin: #"01010101010101",
door: Door { locked: False, hinge_angle: 90 }, door: Door { locked: False, hinge_angle: 90 },
} }
update_door_angle(90, initial_car) == final_car update_door_angle(90, initial_car) == final_car
@ -91,16 +91,16 @@ test update_door_angle1() {
test update_door_locked_and_wheels1() { test update_door_locked_and_wheels1() {
let initial_car = let initial_car =
Car { Car {
owner: #[], owner: #"",
wheels: 4, wheels: 4,
vin: #[1, 1, 1, 1, 1, 1, 1], vin: #"01010101010101",
door: Door { locked: False, hinge_angle: 45 }, door: Door { locked: False, hinge_angle: 45 },
} }
let final_car = let final_car =
Car { Car {
owner: #[], owner: #"",
wheels: 5, wheels: 5,
vin: #[1, 1, 1, 1, 1, 1, 1], vin: #"01010101010101",
door: Door { locked: True, hinge_angle: 45 }, door: Door { locked: True, hinge_angle: 45 },
} }
update_door_locked_and_wheels(True, 5, initial_car) == final_car update_door_locked_and_wheels(True, 5, initial_car) == final_car

View File

@ -0,0 +1 @@

26
examples/acceptance_tests/fmt Executable file
View File

@ -0,0 +1,26 @@
#!/usr/bin/env bash
if [ -z $1 ]; then
echo -e "\033[31mMissing argument: \033[1mACCEPTANCE_TEST\033[0m"
echo ""
echo -e "\033[1mUsage: \033[0m"
echo " run.sh {ACCEPTANCE_TEST}"
echo ""
echo -e "\033[1mExample: \033[0m"
echo " run.sh 034"
exit 1
fi
WORKDIR="$(dirname -- "${BASH_SOURCE[0]}")"
TARGET="$WORKDIR/$(basename $1)"
TMP=$(mktemp)
RESULT=$(cargo run --quiet -- fmt $TARGET 2>$TMP)
if [ "$?" -eq "0" ]; then
echo "✅ $(basename $TARGET)"
else
echo "❌ $(basename $TARGET)"
cat $TMP
exit 1
fi

View File

@ -0,0 +1,3 @@
#!/usr/bin/env bash
find . -regex ".*[0-9]\{3\}" -type d | xargs -P 8 -I {} -- ./fmt {}