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

22
LINES

< > BotCompany Repo | #38 // Test case for PN calculator

Lua code - Test case

-- verifies an evaulator of expressions in PN (polish/prefix notation)
-- expects evaluator as function "solution"
-- returns true upon correct verification

-- assert some stuff for better error messages
assert(log, "log")

function check(output, input)
  local s = tostring(solution(input))
  assert(log, "log")("check "..s)
  if s == output then
    log("OK: "..input.." => "..output)
  else
    log("Oops: "..input.." => "..s.." (expected: "..output..")")
    error("verification failed")
  end
end

check("3", "+ 1 2")
check("6", "* 2 3")

return true

test run  test run with input  pitch  download  show line numbers   

Relations

Travelled to 12 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

Comments [hide]

ID Author/Program Comment Date
407 #1000610 Edit suggestion:
!636
!629

main {
static Object androidContext;
static String programID;

public static void main(String[] args) throws Exception {
-- verifies an evaulator of expressions in PN (polish/prefix notation)
-- expects evaluator as function "solution"
-- returns true upon correct verification

-- assert some stuff for better error messages
assert(log, "log")

function check(output, input)
local s = tostring(solution(input))
assert(log, "log")("check "..s)
if s == output then
log("OK: "..input.." => "..output)
else
log("Oops: "..input.." => "..s.." (expected: "..output..")")
error("verification failed")
end
end

check("3", "+ 1 2")
check("6", "* 2 3")

return true
}}
2015-08-18 13:28:19  delete 
405 #1000604 (pitcher) 2015-08-20 15:28:24

add comment

Image recognition results

Recognizer Recognition Result Visualize Recalc
#308 577 [visualize]

Snippet ID: #38
Snippet name: Test case for PN calculator
Eternal ID of this version: #38/1
Text MD5: 8d0daf047ece273b96b822b594644fc6
Author: stefan
Category:
Type: Lua code - Test case
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2013-12-21 07:14:22
Source code size: 577 bytes / 22 lines
Pitched / IR pitched: Yes / Yes
Views / Downloads: 1779 / 559
Referenced in: #1002212 - alternate splash page
#1002216 - splash page + talk to bot
#1002238 - splash page + talk to bot
#1002251 - homepage test snippet
#1002253 - mobile home page
#1002264 - web version
#1002343 - Homepage + speech recognition
#1002347 - speech enabled homepage
#1002350 - speech enabled mobile
#1002387 - splash page + talk to bot
#1002450 - mobile home page (modified)
#1002609 - splash page + talk to bot
#3000382 - Answer for ferdie (>> t = 1, f = 0)
#3000383 - Answer for funkoverflow (>> t=1, f=0 okay)