--- /dev/null
+use strictures;
+
+use Test::More;
+
+{
+ use Web::Simple 'RunTest';
+
+ package RunTest;
+ use Moo;
+ has test => is => ro => default => sub { 2 };
+ sub to_psgi_app { "to_psgi_app" }
+ sub run { @_, "run" }
+}
+
+is(
+ sub { RunTest->run_if_script }
+ ->(),
+ "to_psgi_app",
+ "to_psgi_app is called when run_if_script is called inside a function"
+);
+
+is(
+ ( RunTest->run_if_script )[0]->test, #
+ 2,
+ "calling run_if_script on a class name instantiates it and runs it"
+);
+
+my $rt = RunTest->new( test => 3 );
+
+is_deeply(
+ [ $rt->run_if_script ], #
+ [ $rt, $rt, "run" ],
+ "calling run_if_script on an object runs it directly"
+);
+
+is_deeply(
+ [ $rt->run_if_script( 4 ) ], #
+ [ $rt, $rt, 4, "run" ],
+ "passing arguments to run_if_script has them passed on to the run method"
+);
+
+done_testing;