aboutsummaryrefslogtreecommitdiff
path: root/spec/result_spec.cr
diff options
context:
space:
mode:
authorMatthew Hall <hallmatthew314@gmail.com>2023-03-31 21:48:41 +1300
committerMatthew Hall <hallmatthew314@gmail.com>2023-03-31 21:48:41 +1300
commitfdfce3d4c7a672fdff10e91bf5a4808cd4d46c4d (patch)
treeb210f79d12a3018a3db15c1fc64dd347eb9da1f4 /spec/result_spec.cr
parent97be6f4ca3f35b0999a36d647716f77c0300d5d7 (diff)
Separate core tests into separate files
Diffstat (limited to 'spec/result_spec.cr')
-rw-r--r--spec/result_spec.cr20
1 files changed, 20 insertions, 0 deletions
diff --git a/spec/result_spec.cr b/spec/result_spec.cr
new file mode 100644
index 0000000..094713e
--- /dev/null
+++ b/spec/result_spec.cr
@@ -0,0 +1,20 @@
+require "./spec_helper"
+
+include Parcom
+
+describe Result do
+ describe "#map" do
+ r = Result.new(Tokens.from_string("abcd"), 'x')
+ r_expected = Result.new(Tokens.from_string("abcd"), 'x'.ord)
+
+ it "accepts a proc" do
+ f = ->(c : Char) { c.ord }
+ r.map(f).should eq(r_expected)
+ end
+
+ it "accepts a block" do
+ r.map { |c| c.ord }.should eq(r_expected)
+ end
+ end
+end
+