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

16
LINES

< > BotCompany Repo | #1023149 // testAttractorBotResponse

JavaX fragment (include)

1  
svoid testAttractorBotResponse(AttractorBot bot, S input, S expectedOutput, O... _) {
2  
  bool fail = !boolPar noFail(_);
3  
  new LS out;
4  
  temp tempSet(bot, say := vfAddToCollection(out));
5  
  bot.addInput(input);
6  
  if (empty(expectedOutput)) {
7  
    if (!empty(out)) ret with failOrWarn(fail, "Bot returned unexpected output: " + multiLineQuote(lines_rtrim(out)));
8  
  } else {
9  
    if (!cic(out, expectedOutput))
10  
      ret with failOrWarn(fail, "Bot didn't return " + multiLineQuote(expectedOutput) + ", instead said: " + multiLineQuote(lines_rtrim(out)));
11  
    print("OK, bot said: " + first(out));
12  
    LS rest = listWithoutIC(out, expectedOutput);
13  
    if (nempty(rest))
14  
      ret with failOrWarn(fail, "Bot returned additional lines: " + rest);
15  
  }
16  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1023149
Snippet name: testAttractorBotResponse
Eternal ID of this version: #1023149/12
Text MD5: f1f47d8176b620e4bec61cefe04d0514
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-05-19 12:17:10
Source code size: 758 bytes / 16 lines
Pitched / IR pitched: No / No
Views / Downloads: 284 / 339
Version history: 11 change(s)
Referenced in: [show references]