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

36
LINES

< > BotCompany Repo | #1000890 // "what time is it" (test case on #1000887, works)

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Libraryless. Click here for Pure Java version (1849L/15K/44K).

!747

m {
  static Class prog;
  
  p {
    prog = hotwire("#1000887");
    
    setClock(15, 34);
    ask("what time is it?");
    expect("It is 15:34.");
  }
  
  static void setClock(int h, int m) ctex {
    long now; // (h*60+m)*60*1000L
    Date date = new java.text.SimpleDateFormat("HH:mm").parse("15:34");
    now = date.getTime();
    print("date: " + date + ", now: " + now);
    setOpt(prog, "now_virtualTime", now);
  }
  
  static void ask(S q) {
    set(prog, "question", q);
    callMain(prog);
  }
  
  static void expect(S a) {
    S answer = cast get(prog, "answer");
    if (a.equals(answer))
      print("OK: " + answer);
    else {
      print("Wrong: " + answer);
      print("Expected: " + a);
    }
  }
}

Author comment

Began life as a copy of #1000875

download  show line numbers  debug dex  old transpilations   

Travelled to 16 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, iveijnkanddl, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, teubizvjbppd, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1000890
Snippet name: "what time is it" (test case on #1000887, works)
Eternal ID of this version: #1000890/1
Text MD5: ec5988cb60af578798ee73a4b68aac54
Transpilation MD5: 7f9028a57a68d9cf511a965e00d21d96
Author: stefan
Category: javax
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-09-05 18:46:01
Source code size: 763 bytes / 36 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 640 / 729
Referenced in: #3000382 - Answer for ferdie (>> t = 1, f = 0)
#3000383 - Answer for funkoverflow (>> t=1, f=0 okay)