currying.t 394 B

12345678910111213141516171819202122232425262728293031323334
  1. #!perl -T
  2. use utf8;
  3. use 5.006;
  4. use strict;
  5. use warnings;
  6. use Test::More;
  7. plan tests => 1;
  8. use Sidef;
  9. my $code = <<'EOT';
  10. func curry(f, *args1) {
  11. func (*args2) {
  12. f(args1..., args2...);
  13. }
  14. }
  15. func add(a, b) {
  16. a + b
  17. }
  18. var adder = curry(add, 13);
  19. adder(29);
  20. EOT
  21. my $sidef = Sidef->new(name => 'currying');
  22. my $result = $sidef->execute_code($code);
  23. is("$result", "42");