Permalink
Browse files

Implement unary minus correctly.

  • Loading branch information...
Arlen Christian Mart Cuss
Arlen Christian Mart Cuss committed Dec 3, 2012
1 parent 9785fdb commit a269d1e24a28dbabdc965678ea74af2d1176e8a8
Showing with 8 additions and 2 deletions.
  1. +3 −1 lib/boot.rg
  2. +1 −1 lib/rouge/reader.rb
  3. +4 −0 spec/reader_spec.rb
View
@@ -108,7 +108,9 @@
(reduce .+ args)))
(defn - [a & args]
- (reduce .- (concat (list a) args)))
+ (if (= () args)
+ (.-@ a)
+ (reduce .- (concat (list a) args))))
(defn * [& args]
(if (empty? args)
View
@@ -427,7 +427,7 @@ def read_number s
)\z
/ox
- SYMBOL = /^(\.\[\])|([a-zA-Z0-9\-_!&\?\*\/\.\+\|=%$<>#]+)/
+ SYMBOL = /^(\.\[\])|(\.?[-+]@)|([a-zA-Z0-9\-_!&\?\*\/\.\+\|=%$<>#]+)/
end
# vim: set sw=2 et cc=80:
View
@@ -73,6 +73,10 @@
it { @ns.read("<").should eq Rouge::Symbol[:"<"] }
it { @ns.read("%50").should eq Rouge::Symbol[:"%50"] }
it { @ns.read("xyz#").should eq Rouge::Symbol[:"xyz#"] }
+ it { @ns.read("-@").should eq Rouge::Symbol[:-@] }
+ it { @ns.read(".-@").should eq Rouge::Symbol[:".-@"] }
+ it { @ns.read("+@").should eq Rouge::Symbol[:+@] }
+ it { @ns.read(".+@").should eq Rouge::Symbol[:".+@"] }
end
describe "keywords" do

0 comments on commit a269d1e

Please sign in to comment.