Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

53
LINES

< > BotCompany Repo | #1028000 // test_tok_defaultArguments

JavaX fragment (include) [tags: use-pretranspiled]

Transpiled version (6972L) is out of date.

svoid test_tok_defaultArguments() {
  forEachLL(s -> print(applyTranspilationFunction tok_defaultArguments(s)),
    "public default void replaceValue(A oldValue, A newValue) {}",
    "static <A> ReturnType method(S arg1, S arg2 default blubb, S arg3) {}",
    "static S method(X a default new X(), S arg2) {}",
    "static S method(L<X> a default new L) {}",
    [[ifdef NoNanoHTTPD static virtual NanoHTTPD.Response serve404(S msg default "Not found") {]],
  );
  
  testTranspilationFunction tok_defaultArguments(
    "sS hjs(S script, O... _ default (O[]) null) {}",
      "sS hjs(S script) { return hjs(script, (O[]) null); }\n" +
      "sS hjs(S script, O... _) {}",
     
    // combine with aka 
    "S a aka b(D e, F g default h) { ret i; }",
      "S a aka b(D e) { return a(e, h); }\n" +
      "S a aka b(D e, F g) { ret i; }",
      
    "S nuLike a aka b(D e, F g default h) { ret i; }",
      "S nuLike a aka b(D e) { return a(e, h); }\n" +
      "S nuLike a aka b(D e, F g) { ret i; }",
     
    // default methods 
    "default S bla(int i default 5) { ret str(i); }",
      "default S bla() { return bla(5); }\n" +
      "default S bla(int i) { ret str(i); }",
      
    // abstract methods
    "abstract S bla(int i default 5);",
      "S bla() { return bla(5); }\n" +
      "abstract S bla(int i);",
      
    // method in an interface
    "S bla(int i default 5);",
      "default S bla() { return bla(5); }\n" +
      "S bla(int i);",
      
    // star constructor with default argument
    "*(S x, S y default null) { bla; }",
    [[ *(S x) { this(x, null); }
       *(S x, S y) { bla; } ]],
       
    // two default arguments!
    "void a(B b default c, D e default g) { x; }",
      [[
        void a() { a(c); }
        void a(B b) { a(b, g); }
        void a(D e) { a(c, e); }
        void a(B b, D e) { x; }
      ]],
  );
}

Author comment

Began life as a copy of #1027998

download  show line numbers  debug dex  old transpilations   

Travelled to 9 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1028000
Snippet name: test_tok_defaultArguments
Eternal ID of this version: #1028000/28
Text MD5: f7d438b0fec2d5180954e200c6a31e1b
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-03-10 16:53:10
Source code size: 1908 bytes / 53 lines
Pitched / IR pitched: No / No
Views / Downloads: 223 / 474
Version history: 27 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1030980 - test_tok_akaFunctionNames
#1033198 - test_tok_scaffoldedFunctions
#1033837 - test_tok_optionalArguments