Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Implement unary minus correctly.

  • Loading branch information...
commit a269d1e24a28dbabdc965678ea74af2d1176e8a8 1 parent 9785fdb
@kivikakk kivikakk authored
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
4 lib/boot.rg
@@ -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
2  lib/rouge/reader.rb
@@ -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
4 spec/reader_spec.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.