Skip to content

Commit

Permalink
add test for curry optimization that is a reduced case of #945
Browse files Browse the repository at this point in the history
  • Loading branch information
MicroProofs committed May 22, 2024
1 parent c3ad52b commit 3d06129
Show file tree
Hide file tree
Showing 35 changed files with 111 additions and 36 deletions.
77 changes: 76 additions & 1 deletion crates/uplc/src/optimize/shrinker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ impl DefaultFunction {
if let (Constant::Integer(i), Constant::ByteString(_)) =
(c.as_ref(), c2.as_ref())
{
i >= &0.into() && i < &255.into()
i >= &0.into() && i < &256.into()
} else {
false
}
Expand Down Expand Up @@ -2817,4 +2817,79 @@ mod tests {

compare_optimization(expected, program, |p| p.builtin_curry_reducer());
}

#[test]
fn curry_reducer_test_4() {
let program: Program<Name> = Program {
version: (1, 0, 0),
term: Term::bool(true)
.delayed_if_then_else(
Term::integer(2.into()),
Term::add_integer()
.apply(
Term::add_integer()
.apply(Term::var("x"))
.apply(Term::var("y")),
)
.apply(Term::var("z"))
.lambda("z")
.apply(
Term::index_bytearray()
.apply(Term::byte_string(vec![
1, 2, 4, 8, 16, 32, 64, 128, 255, 255,
]))
.apply(Term::integer(35.into())),
)
.lambda("y")
.apply(
Term::index_bytearray()
.apply(Term::byte_string(vec![
1, 2, 4, 8, 16, 32, 64, 128, 255, 255,
]))
.apply(Term::integer(35.into())),
),
)
.lambda("x")
.apply(
Term::bool(true).delayed_if_then_else(
Term::integer(1.into()),
Term::index_bytearray()
.apply(Term::byte_string(vec![
1, 2, 4, 8, 16, 32, 64, 128, 255, 255,
]))
.apply(Term::integer(35.into())),
),
),
};

let expected = Program {
version: (1, 0, 0),
term: Term::bool(true)
.delayed_if_then_else(
Term::integer(2.into()),
Term::add_integer()
.apply(
Term::add_integer()
.apply(Term::var("x"))
.apply(Term::var("y")),
)
.apply(Term::var("z"))
.lambda("z")
.apply(Term::var("good_curry").apply(Term::integer(35.into())))
.lambda("y")
.apply(Term::var("good_curry").apply(Term::integer(35.into()))),
)
.lambda("x")
.apply(Term::bool(true).delayed_if_then_else(
Term::integer(1.into()),
Term::var("good_curry").apply(Term::integer(35.into())),
))
.lambda("good_curry")
.apply(Term::index_bytearray().apply(Term::byte_string(vec![
1, 2, 4, 8, 16, 32, 64, 128, 255, 255,
]))),
};

compare_optimization(expected, program, |p| p.builtin_curry_reducer());
}
}
2 changes: 1 addition & 1 deletion examples/acceptance_tests/036/aiken.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ requirements = []
source = "github"

[etags]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1716306925, nanos_since_epoch = 780731000 }, "3d3d948e66503986746dfdf33ca5e80ac634b356c928321987188473d813b2db"]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1716407096, nanos_since_epoch = 481443000 }, "6b89f2c51314a7bc2cc377d37c9eade9a4239086fe636ac6030c6979182f1247"]
2 changes: 1 addition & 1 deletion examples/acceptance_tests/036/plutus.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"plutusVersion": "v2",
"compiler": {
"name": "Aiken",
"version": "v1.0.26-alpha+a3c14d8"
"version": "v1.0.26-alpha+c3ad52b"
}
},
"validators": [
Expand Down
2 changes: 1 addition & 1 deletion examples/acceptance_tests/047/plutus.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"plutusVersion": "v2",
"compiler": {
"name": "Aiken",
"version": "v1.0.26-alpha+a3c14d8"
"version": "v1.0.26-alpha+c3ad52b"
}
},
"validators": [
Expand Down
2 changes: 1 addition & 1 deletion examples/acceptance_tests/054/aiken.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ requirements = []
source = "github"

[etags]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1716306848, nanos_since_epoch = 135217000 }, "3d3d948e66503986746dfdf33ca5e80ac634b356c928321987188473d813b2db"]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1716407101, nanos_since_epoch = 859911000 }, "6b89f2c51314a7bc2cc377d37c9eade9a4239086fe636ac6030c6979182f1247"]
2 changes: 1 addition & 1 deletion examples/acceptance_tests/055/aiken.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ requirements = []
source = "github"

[etags]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1715360626, nanos_since_epoch = 688536000 }, "3d3d948e66503986746dfdf33ca5e80ac634b356c928321987188473d813b2db"]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1716407096, nanos_since_epoch = 167055000 }, "6b89f2c51314a7bc2cc377d37c9eade9a4239086fe636ac6030c6979182f1247"]
2 changes: 1 addition & 1 deletion examples/acceptance_tests/061/aiken.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ requirements = []
source = "github"

[etags]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1715360648, nanos_since_epoch = 285283000 }, "3d3d948e66503986746dfdf33ca5e80ac634b356c928321987188473d813b2db"]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1716407110, nanos_since_epoch = 628540000 }, "6b89f2c51314a7bc2cc377d37c9eade9a4239086fe636ac6030c6979182f1247"]
2 changes: 1 addition & 1 deletion examples/acceptance_tests/063/aiken.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ requirements = []
source = "github"

[etags]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1715360637, nanos_since_epoch = 160057000 }, "3d3d948e66503986746dfdf33ca5e80ac634b356c928321987188473d813b2db"]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1716407094, nanos_since_epoch = 891156000 }, "6b89f2c51314a7bc2cc377d37c9eade9a4239086fe636ac6030c6979182f1247"]
2 changes: 1 addition & 1 deletion examples/acceptance_tests/067/aiken.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ requirements = []
source = "github"

[etags]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1715360653, nanos_since_epoch = 967271000 }, "3d3d948e66503986746dfdf33ca5e80ac634b356c928321987188473d813b2db"]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1716407114, nanos_since_epoch = 974279000 }, "6b89f2c51314a7bc2cc377d37c9eade9a4239086fe636ac6030c6979182f1247"]
2 changes: 1 addition & 1 deletion examples/acceptance_tests/068/aiken.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ requirements = []
source = "github"

[etags]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1716306849, nanos_since_epoch = 424208000 }, "3d3d948e66503986746dfdf33ca5e80ac634b356c928321987188473d813b2db"]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1716407110, nanos_since_epoch = 818921000 }, "6b89f2c51314a7bc2cc377d37c9eade9a4239086fe636ac6030c6979182f1247"]
2 changes: 1 addition & 1 deletion examples/acceptance_tests/069/aiken.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ requirements = []
source = "github"

[etags]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1715360649, nanos_since_epoch = 140499000 }, "3d3d948e66503986746dfdf33ca5e80ac634b356c928321987188473d813b2db"]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1716407111, nanos_since_epoch = 974946000 }, "6b89f2c51314a7bc2cc377d37c9eade9a4239086fe636ac6030c6979182f1247"]
2 changes: 1 addition & 1 deletion examples/acceptance_tests/070/aiken.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ requirements = []
source = "github"

[etags]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1715360642, nanos_since_epoch = 606269000 }, "3d3d948e66503986746dfdf33ca5e80ac634b356c928321987188473d813b2db"]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1716407088, nanos_since_epoch = 812897000 }, "6b89f2c51314a7bc2cc377d37c9eade9a4239086fe636ac6030c6979182f1247"]
2 changes: 1 addition & 1 deletion examples/acceptance_tests/071/aiken.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ requirements = []
source = "github"

[etags]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1716306847, nanos_since_epoch = 531983000 }, "3d3d948e66503986746dfdf33ca5e80ac634b356c928321987188473d813b2db"]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1716407088, nanos_since_epoch = 266980000 }, "6b89f2c51314a7bc2cc377d37c9eade9a4239086fe636ac6030c6979182f1247"]
2 changes: 1 addition & 1 deletion examples/acceptance_tests/071/plutus.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"plutusVersion": "v2",
"compiler": {
"name": "Aiken",
"version": "v1.0.26-alpha+a3c14d8"
"version": "v1.0.26-alpha+c3ad52b"
}
},
"validators": [
Expand Down
2 changes: 1 addition & 1 deletion examples/acceptance_tests/072/aiken.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ requirements = []
source = "github"

[etags]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1715360635, nanos_since_epoch = 574925000 }, "3d3d948e66503986746dfdf33ca5e80ac634b356c928321987188473d813b2db"]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1716407098, nanos_since_epoch = 612481000 }, "6b89f2c51314a7bc2cc377d37c9eade9a4239086fe636ac6030c6979182f1247"]
2 changes: 1 addition & 1 deletion examples/acceptance_tests/073/aiken.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ requirements = []
source = "github"

[etags]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1716306848, nanos_since_epoch = 948852000 }, "3d3d948e66503986746dfdf33ca5e80ac634b356c928321987188473d813b2db"]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1716407092, nanos_since_epoch = 27004000 }, "6b89f2c51314a7bc2cc377d37c9eade9a4239086fe636ac6030c6979182f1247"]
2 changes: 1 addition & 1 deletion examples/acceptance_tests/074/aiken.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ requirements = []
source = "github"

[etags]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1715360638, nanos_since_epoch = 410285000 }, "3d3d948e66503986746dfdf33ca5e80ac634b356c928321987188473d813b2db"]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1716407107, nanos_since_epoch = 237676000 }, "6b89f2c51314a7bc2cc377d37c9eade9a4239086fe636ac6030c6979182f1247"]
2 changes: 1 addition & 1 deletion examples/acceptance_tests/077/aiken.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ requirements = []
source = "github"

[etags]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1716306933, nanos_since_epoch = 371471000 }, "3d3d948e66503986746dfdf33ca5e80ac634b356c928321987188473d813b2db"]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1716407089, nanos_since_epoch = 703441000 }, "6b89f2c51314a7bc2cc377d37c9eade9a4239086fe636ac6030c6979182f1247"]
2 changes: 1 addition & 1 deletion examples/acceptance_tests/077/plutus.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"plutusVersion": "v2",
"compiler": {
"name": "Aiken",
"version": "v1.0.26-alpha+a3c14d8"
"version": "v1.0.26-alpha+c3ad52b"
}
},
"validators": [
Expand Down
2 changes: 1 addition & 1 deletion examples/acceptance_tests/079/plutus.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"plutusVersion": "v2",
"compiler": {
"name": "Aiken",
"version": "v1.0.26-alpha+a3c14d8"
"version": "v1.0.26-alpha+c3ad52b"
}
},
"validators": [
Expand Down
2 changes: 1 addition & 1 deletion examples/acceptance_tests/082/aiken.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ requirements = []
source = "github"

[etags]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1715360634, nanos_since_epoch = 125413000 }, "3d3d948e66503986746dfdf33ca5e80ac634b356c928321987188473d813b2db"]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1716407089, nanos_since_epoch = 560055000 }, "6b89f2c51314a7bc2cc377d37c9eade9a4239086fe636ac6030c6979182f1247"]
2 changes: 1 addition & 1 deletion examples/acceptance_tests/083/aiken.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ requirements = []
source = "github"

[etags]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1715360633, nanos_since_epoch = 924143000 }, "3d3d948e66503986746dfdf33ca5e80ac634b356c928321987188473d813b2db"]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1716407096, nanos_since_epoch = 162798000 }, "6b89f2c51314a7bc2cc377d37c9eade9a4239086fe636ac6030c6979182f1247"]
2 changes: 1 addition & 1 deletion examples/acceptance_tests/084/aiken.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ requirements = []
source = "github"

[etags]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1715360632, nanos_since_epoch = 258131000 }, "3d3d948e66503986746dfdf33ca5e80ac634b356c928321987188473d813b2db"]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1716407088, nanos_since_epoch = 853030000 }, "6b89f2c51314a7bc2cc377d37c9eade9a4239086fe636ac6030c6979182f1247"]
2 changes: 1 addition & 1 deletion examples/acceptance_tests/086/aiken.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ requirements = []
source = "github"

[etags]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1716306902, nanos_since_epoch = 886531000 }, "3d3d948e66503986746dfdf33ca5e80ac634b356c928321987188473d813b2db"]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1716407097, nanos_since_epoch = 304608000 }, "6b89f2c51314a7bc2cc377d37c9eade9a4239086fe636ac6030c6979182f1247"]
2 changes: 1 addition & 1 deletion examples/acceptance_tests/086/plutus.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"plutusVersion": "v2",
"compiler": {
"name": "Aiken",
"version": "v1.0.26-alpha+a3c14d8"
"version": "v1.0.26-alpha+c3ad52b"
}
},
"validators": [
Expand Down
2 changes: 1 addition & 1 deletion examples/acceptance_tests/087/aiken.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ requirements = []
source = "github"

[etags]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1715360630, nanos_since_epoch = 494678000 }, "3d3d948e66503986746dfdf33ca5e80ac634b356c928321987188473d813b2db"]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1716407092, nanos_since_epoch = 232992000 }, "6b89f2c51314a7bc2cc377d37c9eade9a4239086fe636ac6030c6979182f1247"]
2 changes: 1 addition & 1 deletion examples/acceptance_tests/088/aiken.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ requirements = []
source = "github"

[etags]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1715360641, nanos_since_epoch = 457964000 }, "3d3d948e66503986746dfdf33ca5e80ac634b356c928321987188473d813b2db"]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1716407097, nanos_since_epoch = 984333000 }, "6b89f2c51314a7bc2cc377d37c9eade9a4239086fe636ac6030c6979182f1247"]
2 changes: 1 addition & 1 deletion examples/acceptance_tests/089/aiken.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ requirements = []
source = "github"

[etags]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1716306912, nanos_since_epoch = 954678000 }, "3d3d948e66503986746dfdf33ca5e80ac634b356c928321987188473d813b2db"]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1716407106, nanos_since_epoch = 432431000 }, "6b89f2c51314a7bc2cc377d37c9eade9a4239086fe636ac6030c6979182f1247"]
2 changes: 1 addition & 1 deletion examples/acceptance_tests/089/plutus.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"plutusVersion": "v2",
"compiler": {
"name": "Aiken",
"version": "v1.0.26-alpha+a3c14d8"
"version": "v1.0.26-alpha+c3ad52b"
}
},
"validators": [
Expand Down
2 changes: 1 addition & 1 deletion examples/acceptance_tests/090/plutus.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"plutusVersion": "v2",
"compiler": {
"name": "Aiken",
"version": "v1.0.26-alpha+a3c14d8"
"version": "v1.0.26-alpha+c3ad52b"
}
},
"validators": [
Expand Down
2 changes: 1 addition & 1 deletion examples/acceptance_tests/096/plutus.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"plutusVersion": "v2",
"compiler": {
"name": "Aiken",
"version": "v1.0.26-alpha+a3c14d8"
"version": "v1.0.26-alpha+c3ad52b"
},
"license": "Apache-2.0"
},
Expand Down
4 changes: 2 additions & 2 deletions examples/acceptance_tests/101/aiken.lock
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ requirements = []
source = "github"

[etags]
"aiken-lang/fuzz@main" = [{ secs_since_epoch = 1716306920, nanos_since_epoch = 138088000 }, "d7aadd4a9b25589bd6d5e3bbedcd809cdf97fe3eddb365cf89cd6ac6bc829643"]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1715360636, nanos_since_epoch = 821658000 }, "3d3d948e66503986746dfdf33ca5e80ac634b356c928321987188473d813b2db"]
"aiken-lang/fuzz@main" = [{ secs_since_epoch = 1716407093, nanos_since_epoch = 166109000 }, "d7aadd4a9b25589bd6d5e3bbedcd809cdf97fe3eddb365cf89cd6ac6bc829643"]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1716407092, nanos_since_epoch = 908456000 }, "6b89f2c51314a7bc2cc377d37c9eade9a4239086fe636ac6030c6979182f1247"]
2 changes: 1 addition & 1 deletion examples/acceptance_tests/102/aiken.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ requirements = []
source = "github"

[etags]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1715360633, nanos_since_epoch = 933401000 }, "3d3d948e66503986746dfdf33ca5e80ac634b356c928321987188473d813b2db"]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1716407088, nanos_since_epoch = 875368000 }, "6b89f2c51314a7bc2cc377d37c9eade9a4239086fe636ac6030c6979182f1247"]
2 changes: 1 addition & 1 deletion examples/acceptance_tests/script_context/aiken.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ requirements = []
source = "github"

[etags]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1716306936, nanos_since_epoch = 675892000 }, "3d3d948e66503986746dfdf33ca5e80ac634b356c928321987188473d813b2db"]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1716407124, nanos_since_epoch = 316651000 }, "6b89f2c51314a7bc2cc377d37c9eade9a4239086fe636ac6030c6979182f1247"]
2 changes: 1 addition & 1 deletion examples/acceptance_tests/script_context/plutus.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"plutusVersion": "v2",
"compiler": {
"name": "Aiken",
"version": "v1.0.26-alpha+a3c14d8"
"version": "v1.0.26-alpha+c3ad52b"
}
},
"validators": [
Expand Down

0 comments on commit 3d06129

Please sign in to comment.