This repository was archived by the owner on Dec 28, 2024. It is now read-only.
File tree Expand file tree Collapse file tree
test/workspaces/smoke_test_java_rule_attributes/attrs/args Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ load ("@dwtj_rules_java//java:defs.bzl" , "dwtj_java_test" )
2+
3+ dwtj_java_test (
4+ name = "expect_zero_args" ,
5+ main_class = "attrs.args.ExpectNumArgs" ,
6+ srcs = ["ExpectNumArgs.java" ],
7+ args = [],
8+ )
9+
10+ dwtj_java_test (
11+ name = "expect_one_arg" ,
12+ main_class = "attrs.args.ExpectNumArgs" ,
13+ srcs = ["ExpectNumArgs.java" ],
14+ args = ["1" ],
15+ )
16+
17+ dwtj_java_test (
18+ name = "expect_five_args" ,
19+ main_class = "attrs.args.ExpectNumArgs" ,
20+ srcs = ["ExpectNumArgs.java" ],
21+ args = [
22+ "5" ,
23+ "a" ,
24+ "b" ,
25+ "c" ,
26+ "d" ,
27+ ],
28+ )
Original file line number Diff line number Diff line change 1+ package attrs .args ;
2+
3+ public class ExpectNumArgs {
4+ public static void main (String [] args ) {
5+ if (args .length == 0 ) {
6+ System .exit (0 );
7+ }
8+
9+ int numArgs = Integer .parseInt (args [0 ]);
10+ if (args .length != numArgs ) {
11+ System .err .println ("Wrong number of arguments found." );
12+ System .err .println ("Expected number of args: " + numArgs );
13+ System .err .println ("Actual number of args: " + args .length );
14+ System .exit (-1 );
15+ } else {
16+ for (String arg : args ) {
17+ System .out .println (arg );
18+ }
19+ System .exit (0 );
20+ }
21+ }
22+ }
You can’t perform that action at this time.
0 commit comments