from test/more import *;

is( 4 ▷ ^^ + 1, 5, "rightwards chain binds the left value" );
is( 4 |> ^^ + 1, 5, "rightwards ASCII chain alias binds the left value" );
is( ^^ + 1 ◁ 4, 5, "leftwards chain binds the right value" );
is( ^^ + 1 <| 4, 5, "leftwards ASCII chain alias binds the right value" );

is(
	1 ▷ ^^ + 1 ▷ ^^ * 10,
	20,
	"rightwards chains associate left-to-right",
);
is(
	^^ * 10 ◁ ^^ + 1 ◁ 1,
	20,
	"leftwards chains associate right-to-left",
);

let outer := 10 ▷ ( 3 ▷ ^^ + 4 ) + ^^;
is( outer, 17, "nested chains shadow the placeholder only inside the nested chain" );

let capture := 12 ▷ function() {
	return ^^;
};
is( capture(), 12, "functions created inside chains capture the placeholder value" );

like(
	exception( function() {
		return ^^;
	} ),
	/Undeclared|undeclared/,
	"placeholder outside a chain is undeclared at runtime",
);

done_testing();
