Move the demo_account.lua test from fail to pass - yay!

Fri, 19 Nov 2010 03:50:04 +0000

author
Matthew Wild <mwild1@gmail.com>
date
Fri, 19 Nov 2010 03:50:04 +0000
changeset 69
26ee626eda90
parent 68
5b815d3591e2
child 70
29f412ed4bca

Move the demo_account.lua test from fail to pass - yay!

tests/fail/demo_account.lua file | annotate | diff | comparison | revisions
tests/pass/demo_account.lua file | annotate | diff | comparison | revisions
--- a/tests/fail/demo_account.lua	Fri Nov 19 03:48:41 2010 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,38 +0,0 @@
--- account.lua
--- from PiL 1, Chapter 16
-
-Account = {balance = 0}
-
-function Account:new (o, name)
-  o = o or {name=name}
-  setmetatable(o, self)
-  self.__index = self
-  return o
-end
-
-function Account:deposit (v)
-  self.balance = self.balance + v
-end
-
-function Account:withdraw (v)
-  if v > self.balance then error("insufficient funds on account "..self.name) end
-  self.balance = self.balance - v
-end
-
-function Account:show (title)
-  print(title or "", self.name, self.balance)
-end
-
-a = Account:new(nil,"demo")
-a:show("after creation")
-a:deposit(1000.00)
-a:show("after deposit")
-a:withdraw(100.00)
-a:show("after withdraw")
-
--- this would raise an error
---[[
-b = Account:new(nil,"DEMO")
-b:withdraw(100.00)
---]]
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/pass/demo_account.lua	Fri Nov 19 03:50:04 2010 +0000
@@ -0,0 +1,38 @@
+-- account.lua
+-- from PiL 1, Chapter 16
+
+Account = {balance = 0, name = "base"}
+Account.__index = Account;
+
+function Account:new (o, name)
+  o = o or {name=name}
+  setmetatable(o, self)
+  return o
+end
+
+function Account:deposit (v)
+  self.balance = self.balance + v
+end
+
+function Account:withdraw (v)
+  if v > self.balance then error("insufficient funds on account "..self.name) end
+  self.balance = self.balance - v
+end
+
+function Account:show (title)
+  print(title or "", self.name, self.balance)
+end
+
+a = Account:new(nil,"demo")
+a:show("after creation")
+a:deposit(1000.00)
+a:show("after deposit")
+a:withdraw(100.00)
+a:show("after withdraw")
+
+-- this would raise an error
+--[[
+b = Account:new(nil,"DEMO")
+b:withdraw(100.00)
+--]]
+

mercurial