<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -9,7 +9,7 @@ Explaination:
 
 Example:
   -- Describe a context
-  describe (&quot;string&quot;)
+  describe &quot;string&quot;
   {
     -- setup [optional]
     before = function(self)
@@ -44,14 +44,19 @@ spec = {
 spec.report = function ()
   local total = spec.passed + spec.failed
   local percent = spec.passed/total*100
+  local contexts = spec.contexts
   local summery
+  
   if spec.failed == 0 and not spec.verbose then
     print &quot;all tests passed&quot;
     return
   end
   
-  for context, cases in pairs(spec.contexts) do
+  -- HACK: preserve hash ordering
+  for index = 1, #contexts do
+    local context, cases = contexts[index], contexts[contexts[index]]
     print ((&quot;%s\n================================&quot;):format(context))
+    
     for description, result in pairs(cases) do
       local outcome = result.passed and 'pass' or &quot;FAILED&quot;
 
@@ -144,8 +149,11 @@ function expect(target)
       end
 
       local success, message = matchers[method](self, ...)
-      spec.current.passed = success
-
+      
+      if spec.current.passed then
+        spec.current.passed = success
+      end
+      
       if success then
         spec.passed = spec.passed + 1
       else
@@ -168,13 +176,17 @@ value_of = expect
 -- Descript a context
 -- 
 function describe(context)
+
+  -- Hack reserve hash ordering
+  spec.contexts[#spec.contexts+1] = context
   spec.contexts[context] = {}
+  local context = spec.contexts[context]
   
   return function(specs)
     local instance = {}
     local before = specs.before and specs.before or nil
     local after = specs.after and specs.after or nil
-    
+
     -- prepare
     if before then
       specs.before = nil
@@ -186,10 +198,8 @@ function describe(context)
 
     -- run
     for description, example in pairs(specs) do
-      spec.contexts[context][description] = { 
-        passed = false, errors = {}
-      }
-      spec.current = spec.contexts[context][description]
+      context[description] = { passed = true, errors = {} }
+      spec.current = context[description]
       example(instance)
     end
  </diff>
      <filename>loonar/spec.lua</filename>
    </modified>
    <modified>
      <diff>@@ -1,32 +1,30 @@
-describe ('array') 
+describe &quot;array - standard access&quot;
 {
   before = function(self)
-    self.list = a{888}
+    self.list = a{888, 999, 566, 444, 112}
   end;
   
-  [&quot;array.first should return the first element&quot;] = function(self)
-    expect(self.list.first).should_be(self.list[1])
+  [&quot;sets item value by idex&quot;] = function(self)
+    self.list[2] = 22
+    expect(self.list[2]).should_be(22)
+    expect(self.list[2]).should_not_be(999)
   end;
   
-  [&quot;array.last should return the last element&quot;] = function(self)
-    expect(self.list.last).should_be(self.list[#self.list])
+  [&quot;gets item by index&quot;] = function(self) 
+    expect(self.list[1]).should_be(888)
+    expect(self.list[5]).should_be(112)
   end;
   
-  [&quot;allows insertion of elements&quot;] = function(self)
-    self.list[2] = 22
-    expect(self.list[2]).should_be(22)
+  [&quot;array.first should return the first element&quot;] = function(self)
+    expect(self.list.first).should_be(self.list[1])
   end;
   
-  [&quot;allows array access&quot;] = function(self) 
-    expect(self.list[1]).should_be(888)
-
-    -- Failed expectation
-    expect(self.list[2]).should_be(2)
-    expect(true).should_be(false)
+  [&quot;array.last should return the last element&quot;] = function(self)
+    expect(self.list.last).should_be(self.list[#self.list])
   end;
 }
 
-describe ('array - iterator') 
+describe &quot;array - iterator&quot;
 {
   before = function(self)
     self.list = a{1,2,3,4,5} 
@@ -40,23 +38,23 @@ describe ('array - iterator')
   end;
 }
 
-describe ('array - transformation iterator') 
+describe &quot;array - transformation iterator&quot;
 {
-	before = function(self)
-		self.list = a{111,222,333,444}
-	end;
-	
-	[&quot;array#map should return transformed array&quot;] = function(self)
-	
-		local result = self.list.map(function(value, key) 
-	    return value + 1
-	  end)
-		
-		type_of(result).should_be 'table'
-		expect(result).should_be(a{112,223,334,445})
-		expect(self.list).should_be(a{111,222,333,444})
-	end;
-	
+  before = function(self)
+    self.list = a{111,222,333,444}
+  end;
+  
+  [&quot;array#map should return transformed array&quot;] = function(self)
+  
+    local result = self.list.map(function(value, key) 
+      return value + 1
+    end)
+    
+    type_of(result).should_be 'table'
+    expect(result).should_be(a{112,223,334,445})
+    expect(self.list).should_be(a{111,222,333,444})
+  end;
+  
   [&quot;array#reduce reduces reduces to singular value&quot;] = function(self)
     local result = self.list.reduce(0, function(sum, value) 
       return sum + value
@@ -67,50 +65,42 @@ describe ('array - transformation iterator')
   end;
 }
 
-describe (&quot;array - conditional iterator&quot;) 
+describe &quot;array - conditional iterator&quot;
 {
   before = function(self)
     self.list = a{111,222,333,444}
   end;
   
   [&quot;array#any requires condition met with any item&quot;] = function(self)
+    local r1 = self.list.any(function(e) return e &gt; 400 end)
+    local r2 = self.list.any(function(e) return e &gt; 500 end)
+    
+    expect(r1).should_be_true()
+    expect(r2).should_be_false()
+  end;
   
-    local result = self.list.any(function(e) return e &gt; 400 end)
-    expect(result).should_be_true()
+  [&quot;array#all requires condition met with all items&quot;] = function(self)
+    local r1 = self.list.all(function(e) return e &gt; 1 end)
+    local r2 = self.list.all(function(e) return e &gt; 200 end)
 
-	result = self.list.any(function(e) return e &gt; 500 end)
-	expect(result).should_be_false()
-		
-  end;
-	
-	[&quot;array#all requires condition met with all items&quot;] = function(self)
-	
-		local result = self.list.all(function(e) return e &gt; 1 end)
-		expect(result).should_be_true()
-		
-		result = self.list.all(function(e) return e &gt; 200 end)
-		expect(result).should_be_false()
-		
-	end;
-	
-	[&quot;array#contains require if element exists&quot;] = function(self)
-	
-		expect(self.list.contains(333)).should_be_true()	
-		expect(self.list.contains(3)).should_be_false()
-		
-	end;
-	
-	[&quot;array#filter should return all element met given condition&quot;] = function(self)
-	
-	  local result = self.list.filter(function(e) return e &gt; 300 end)  
-	
-		expect(result).should_be(a{333,444})
-		expect(result == a{}).should_be_false()
-		
-	end;
+    expect(r1).should_be_true()
+    expect(r2).should_be_false()
+  end;
+  
+  [&quot;array#contains require if element exists&quot;] = function(self)
+    expect(self.list.contains(333)).should_be_true()  
+    expect(self.list.contains(3)).should_be_false()
+  end;
+  
+  [&quot;array#filter should return all elements met given condition&quot;] = function(self)
+    local result = self.list.filter(function(e) return e &gt; 300 end)  
+  
+    expect(result).should_be(a{333,444})
+    expect(result == a{}).should_be_false()
+  end;
 }
 
-describe (&quot;array - utilities&quot;)
+describe &quot;array - utilities&quot;
 {
   [&quot;array#merge&quot;] = function(self)
     expect(a{1, 2}.merge(a{3, 4})).should_be(a{1, 2, 3, 4})
@@ -118,17 +108,15 @@ describe (&quot;array - utilities&quot;)
 
   [&quot;array#flatten should flatten a multidimensional array into a single array&quot;] = function(self)
     local array = a{
-		1, 2, 3, 4, a{a{5}, 6, 7, 8, a{9, 10, a{11}, 12, 13}, 14, a{15, 16}},
-		17, 18, a{a{a{a{a{a{19}}}}}}, 20, 21, a{22, a{23, a{24, a{25}}}}
-	}
-
-	expect(array.flatten()).should_be(a{
-		 1,  2,  3,  4,  5,
-		 6,  7,  8,  9, 10,
-		11, 12, 13, 14, 15,
-		16, 17, 18, 19, 20,
-		21, 22, 23, 24, 25
-	})
-
+      1, 2, 3, 4, a{a{5}, 6, 7, 8, a{9, 10, a{11}, 12, 13}, 14, a{15, 16}},
+      17, 18, a{a{a{a{a{a{19}}}}}}, 20, 21, a{22, a{23, a{24, a{25}}}}
+    }
+    expect(array.flatten()).should_be(a{
+       1,  2,  3,  4,  5,
+       6,  7,  8,  9, 10,
+      11, 12, 13, 14, 15,
+      16, 17, 18, 19, 20,
+      21, 22, 23, 24, 25
+    })
   end;
 }</diff>
      <filename>spec/array.lua</filename>
    </modified>
    <modified>
      <diff>@@ -1,7 +1,10 @@
-foo = class {
-  self = function(self)
-    return self
-  end;
+--[[
+  class spec
+]]
+
+-- Simple foo class
+local foo = class {
+  self = function(self) return self end;
 
   ['+'] = function(self, operand)
     return '+ ' .. tostring(operand)
@@ -16,72 +19,19 @@ foo = class {
   end;
 }
 
-describe('class - simple class foo') {
-  before = function(self)
-    self.f = foo { name = 'foo'; bar = true; }
-  end;
-  
-  [&quot;builds default constructor for class foo&quot;] = function(self)
-    type_of(
-      getmetatable(self.f).class.initialize
-    ).should_be 'function'
-  end;
-  
-  [&quot;should be instance of foo, class&quot;] = function(self)
-    expect(foo.is_domain_of(self.f)).should_be_true()
-    expect(class().is_domain_of(self.f)).should_be_false()
-  end;
-  
-  [&quot;shuold be subclass of table&quot;] = function(self)
-    expect(foo.is_subclass_of(table)).should_be_true()
-  end;
-  
-  [&quot;property and method access&quot;] = function(self)
-    local f= self.f
-    expect(f.self()).should_be(f)
-    
-    expect(f.name).should_be 'foo'
-    expect(tostring(f)).should_be 'foo'
-    
-    expect(f.bar).should_be_true()
-  end;
-  
-  [&quot;overloads operators, setter and getters&quot;] = function(self)
-    local f = self.f
-    expect( f + 123 ).should_be '+ 123'
-    
-    expect( f[123] ).should_be(123)
-    
-    expect( f[f] ).should_be(f)
-    expect( f.abc ).should_be 'abc'
-    
-    expect(tostring(f)).should_be(f.name)
-  end
-}
-
--- person Class Example
-
-person = class {
-  function(self, name, age)
-    self.name = name
-    self.age = age
+-- person class
+local person = class {
+  function(self, name, age, location)
+    self.name, self.age  = name, age
+    self.location = location
   end;
-  
-  destory = function(self) end;
-}
 
-describe('class - person class') 
-{
-  ['constructor should set person property'] = function(self)
-    p1 = person('Taylor luk', 26)
-
-    expect( p1.name ).should_be 'Taylor luk'
-    expect( p1.age ).should_be(26)
+  geolocation = function(self)
+    return self.location
   end;
 }
 
 -- complex class example
-
 complex = class {
   initialize = function(self, real, imaginary)
     self.real, self.imaginary = real, imaginary
@@ -110,10 +60,79 @@ complex = class {
   end;
 }
 
-describe ('class - complex class') 
-{
+describe &quot;class - constructor&quot;
+{ 
+  before = function(self) 
+    self.f = foo { name = 'foo'; bar = true; }
+  end;
+  
+  ['should accept argument and set object property'] = function(self)
+    p1 = person('Taylor luk', 26)
+    
+    expect( p1.name ).should_be 'Taylor luk'
+    expect( p1.age ).should_be(26)
+  end;
+
+  [&quot;builds instance of a class &quot;] = function(self)
+    expect(foo.is_domain_of(self.f)).should_be_true()
+    expect(class().is_domain_of(self.f)).should_be_false()
+  end;
+  
+  
+  [&quot;where class should be subclass of table&quot;] = function(self)
+    expect(foo.is_subclass_of(table)).should_be_true()
+  end;
+  
+  [&quot;builds default constructor for method-less class &quot;] = function(self)
+    local result = getmetatable(self.f).class.initialize
+    
+    type_of(result).should_be 'function'
+  end;
+
+}
+
+describe &quot;class - property and method access&quot;
+{ 
+  before = function(self)
+    self.f = foo { name = 'foo'; bar = true; }
+    self.p = person ('taylor luk', 26, 'Sydney Australia')
+  end;
+
+  [&quot;allows property access&quot;] = function(self)
+    local f = self.f
+    expect(f.name).should_be 'foo'
+    expect(f.bar).should_be_true()
+  end;
+
+  [&quot;should allow instance method access&quot;] = function(self)
+    local f, p = self.f, self.p
+    expect(f.self()).should_be(f)
+    expect(p.geolocation()).should_be 'Sydney Australia'
+  end;
+
+  [&quot;generic methods available for both instance, class context&quot;] = function(self)
+    expect(self.p.geolocation()).should_be 'Sydney Australia'
+    
+    local p2 = person('minhee', 999, 'Korea, Planet Earth')
+    expect(person.geolocation(p2)).should_be 'Korea, Planet Earth'
+  end;
+}
+
+describe &quot;class - property and operator overload&quot;
+{ 
   before = function(self)
     self.c1, self.c2 = complex(1,2), complex(2,5)
+    self.f = foo { name = 'foo'; bar = true; }
+  end;
+  
+  [&quot;overloads operators, setter and getters&quot;] = function(self)
+    local f = self.f
+    
+    expect( f + 123 ).should_be '+ 123'
+    expect( f[123] ).should_be(123)
+    
+    expect( f[f] ).should_be(f)
+    expect( f.abc ).should_be 'abc'    
   end;
   
   [&quot;overloads arithmetic operations&quot;] = function(self)
@@ -131,4 +150,10 @@ describe ('class - complex class')
     expect(c2 == c2).should_be_true()
     expect(c1 == c2).should_be_false()
   end;
+
+  [&quot;overloads tostring should return string representation&quot;] = function(self)
+    expect(tostring(self.f)).should_be(self.f.name)
+    expect(tostring(self.f)).should_be 'foo'
+  end;
+
 }</diff>
      <filename>spec/class.lua</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>cc5dc07e0489ead8752bcdd3484250e80aef38a4</id>
    </parent>
  </parents>
  <author>
    <name>taylor luk</name>
    <email>subjective@gmail.com</email>
  </author>
  <url>http://github.com/dahlia/loonar/commit/cf862d0d2f0d9495aab9ab89440d62a160232e5f</url>
  <id>cf862d0d2f0d9495aab9ab89440d62a160232e5f</id>
  <committed-date>2008-08-14T06:35:41-07:00</committed-date>
  <authored-date>2008-08-14T06:35:41-07:00</authored-date>
  <message>Fixed context ordering, now they run in correct order (example still unordered), refactor and cleanup array, class spec</message>
  <tree>d2342032e3cd79afeef1b17aef1e4e16e3080973</tree>
  <committer>
    <name>taylor luk</name>
    <email>subjective@gmail.com</email>
  </committer>
</commit>
