Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

+ slices inspect as "string"@1234

This enhances perception of slices as being 'just strings'. It also
makes output easier to read.
  • Loading branch information...
commit f05e00b302983141bdbe3c992576c27fb695e11f 1 parent 075f148
@kschiess authored
View
16 example/output/comments.out
@@ -1,8 +1,8 @@
-[{:exp=>{:a=>slice("a", 3)}},
- {:line=>slice("// line comment", 7)},
- {:exp=>{:a=>slice("a", 25)}},
- {:exp=>{:a=>slice("a", 27)}},
- {:exp=>[{:a=>slice("a", 29)}, {:line=>slice("// line comment", 31)}]},
- {:exp=>[{:a=>slice("a", 49)}, {:multi=>slice("/* inline comment */", 51)}]},
- {:exp=>{:a=>slice("a", 72)}},
- {:multi=>slice("/* multiline\n comment */", 77)}]
+[{:exp=>{:a=>"a"@3}},
+ {:line=>"// line comment"@7},
+ {:exp=>{:a=>"a"@25}},
+ {:exp=>{:a=>"a"@27}},
+ {:exp=>[{:a=>"a"@29}, {:line=>"// line comment"@31}]},
+ {:exp=>[{:a=>"a"@49}, {:multi=>"/* inline comment */"@51}]},
+ {:exp=>{:a=>"a"@72}},
+ {:multi=>"/* multiline\n comment */"@77}]
View
2  example/output/documentation.out
@@ -1 +1 @@
-slice("aaaa", 0)
+"aaaa"@0
@ktlund
ktlund added a note

dette er en test

@floere Collaborator
floere added a note

test lyktes :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
View
6 example/output/erb.out
@@ -1,6 +1,6 @@
-{:text=>[{:text=>slice("The value of x is ", 0)}, {:expression=>{:ruby=>slice(" x ", 21)}}, {:text=>slice(".", 26)}]}
-{:text=>[{:code=>{:ruby=>slice(" 1 + 2 ", 2)}}]}
-{:text=>[{:comment=>{:ruby=>slice(" commented ", 3)}}]}
+{:text=>[{:text=>"The value of x is "@0}, {:expression=>{:ruby=>" x "@21}}, {:text=>"."@26}]}
+{:text=>[{:code=>{:ruby=>" 1 + 2 "@2}}]}
+{:text=>[{:comment=>{:ruby=>" commented "@3}}]}
The not printed result of "a = 2".
The not printed non-evaluated comment "a = 1", see the value of a below.
The nicely printed result.
View
14 example/output/ip_address.out
@@ -1,9 +1,9 @@
- 0.0.0.0 -> {:ipv4=>slice("0.0.0.0", 0)}
- 255.255.255.255 -> {:ipv4=>slice("255.255.255.255", 0)}
+ 0.0.0.0 -> {:ipv4=>"0.0.0.0"@0}
+ 255.255.255.255 -> {:ipv4=>"255.255.255.255"@0}
255.255.255 -> Failed: Expected one of [IPV4, IPV6]. at line 1 char 1.
- 1:2:3:4:5:6:7:8 -> {:ipv6=>slice("1:2:3:4:5:6:7:8", 0)}
- 12AD:34FC:A453:1922:: -> {:ipv6=>slice("12AD:34FC:A453:1922::", 0)}
- 12AD::34FC -> {:ipv6=>slice("12AD::34FC", 0)}
- 12AD:: -> {:ipv6=>slice("12AD::", 0)}
- :: -> {:ipv6=>slice("::", 0)}
+ 1:2:3:4:5:6:7:8 -> {:ipv6=>"1:2:3:4:5:6:7:8"@0}
+ 12AD:34FC:A453:1922:: -> {:ipv6=>"12AD:34FC:A453:1922::"@0}
+ 12AD::34FC -> {:ipv6=>"12AD::34FC"@0}
+ 12AD:: -> {:ipv6=>"12AD::"@0}
+ :: -> {:ipv6=>"::"@0}
1:2 -> Failed: Expected one of [IPV4, IPV6]. at line 1 char 1.
View
4 example/output/local.out
@@ -1,3 +1,3 @@
-{:e=>slice("a", 0), :rec=>{:e=>slice("a", 1), :rec=>{:e=>slice("a", 2), :rec=>{:e=>slice("a", 3), :rec=>nil}}}}
+{:e=>"a"@0, :rec=>{:e=>"a"@1, :rec=>{:e=>"a"@2, :rec=>{:e=>"a"@3, :rec=>nil}}}}
e2:'aa' !. / e1:'a' rec:B
-{:e1=>slice("a", 0), :rec=>{:e1=>slice("a", 1), :rec=>{:e2=>slice("aa", 2)}}}
+{:e1=>"a"@0, :rec=>{:e1=>"a"@1, :rec=>{:e2=>"aa"@2}}}
View
5 example/output/minilisp.out
@@ -2,7 +2,4 @@
:test,
[:lambda,
[],
- [:begin,
- [:display, slice("something", 54)],
- [:display, 1],
- [:display, 3.08]]]]
+ [:begin, [:display, "something"@54], [:display, 1], [:display, 3.08]]]]
View
6 example/output/parens.out
@@ -1,8 +1,8 @@
- (): {:l=>slice("(", 0), :m=>nil, :r=>slice(")", 1)} (1 parens)
+ (): {:l=>"("@0, :m=>nil, :r=>")"@1} (1 parens)
- (()): {:l=>slice("(", 0), :m=>{:l=>slice("(", 1), :m=>nil, :r=>slice(")", 2)}, :r=>slice(")", 3)} (2 parens)
+ (()): {:l=>"("@0, :m=>{:l=>"("@1, :m=>nil, :r=>")"@2}, :r=>")"@3} (2 parens)
- ((((())))): {:l=>slice("(", 0), :m=>{:l=>slice("(", 1), :m=>{:l=>slice("(", 2), :m=>{:l=>slice("(", 3), :m=>{:l=>slice("(", 4), :m=>nil, :r=>slice(")", 5)}, :r=>slice(")", 6)}, :r=>slice(")", 7)}, :r=>slice(")", 8)}, :r=>slice(")", 9)} (5 parens)
+ ((((())))): {:l=>"("@0, :m=>{:l=>"("@1, :m=>{:l=>"("@2, :m=>{:l=>"("@3, :m=>{:l=>"("@4, :m=>nil, :r=>")"@5}, :r=>")"@6}, :r=>")"@7}, :r=>")"@8}, :r=>")"@9} (5 parens)
((()): Failed to match sequence (l:'(' m:(BALANCED?)) at line 1 char 6.
View
2  example/output/simple_xml.out
@@ -1,2 +1,2 @@
"verified"
-{:o=>{:name=>slice("b", 1)}, :i=>"verified", :c=>{:name=>slice("a", 33)}}
+{:o=>{:name=>"b"@1}, :i=>"verified", :c=>{:name=>"a"@33}}
View
6 example/output/string_parser.out
@@ -1,3 +1,3 @@
-[#<struct IntLit text=slice("123", 0)>,
- #<struct IntLit text=slice("12345", 4)>,
- #<struct StringLit text=slice(" Some String with \\\"escapes\\\"", 11)>]
+[#<struct IntLit text="123"@0>,
+ #<struct IntLit text="12345"@4>,
+ #<struct StringLit text=" Some String with \\\"escapes\\\""@11>]
View
2  lib/parslet/slice.rb
@@ -105,7 +105,7 @@ def to_f
# Inspection & Debugging ---------------------------------------------------
def inspect
- "slice(#{str.inspect}, #{offset})"
+ str.inspect << "@#{offset}"
end
end
View
2  spec/acceptance/examples_spec.rb
@@ -1,7 +1,7 @@
require 'spec_helper'
require 'open3'
-describe "Regression examples from example/ directory" do
+describe "Regression on" do
Dir["example/*.rb"].each do |example|
context example do
# Generates a product path for a given example file.
View
10 spec/parslet/slice_spec.rb
@@ -143,5 +143,15 @@
end
end
end
+ describe "inspection and string conversion" do
+ describe "#inspect" do
+ subject { slice.inspect }
+ it { should == '"foobar"@40' }
+ end
+ describe "#to_s" do
+ subject { slice.to_s }
+ it { should == 'foobar' }
+ end
+ end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.