Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Cleanup some cruft.

  • Loading branch information...
commit 94e6daa787868dc795f1fbd2e44c53b92580a88f 1 parent fbcde98
@seancribbs authored
View
3  .gitignore
@@ -1,7 +1,8 @@
ebin/*.beam
+ebin/neotoma.app
extra/*.beam
*#*
.eunit
*#*
.DS_Store
-._*
+._*
View
85 Rakefile
@@ -1,85 +0,0 @@
-require 'rake/clean'
-
-task :default => %w(check_erl_version build test)
-
-# Build rules
-task :build => %w(neotoma)
-task :neotoma => %w(parser compile)
-task :parser => %w(src/neotoma_parse.erl)
-
-# include file
-file "priv/peg_includes.hrl" => ["src/peg_includes.erl"] do
- sh "cat src/peg_includes.erl | grep -v \"^%\" | grep -v \"^-\" > priv/peg_includes.hrl"
- end
-
-# Parser
-if File.exist?("ebin/neotoma_parse.beam")
- file "src/neotoma_parse.erl" => ["src/neotoma_parse.peg", "priv/peg_includes.hrl"] do
- erl_eval 'neotoma:file("src/neotoma_parse.peg")', 'ebin/'
- end
-else
- sh "cp src/neotoma_parse.erl.safe src/neotoma_parse.erl"
-end
-
-task :compile => %w(ebin src/neotoma.app priv/peg_includes.hrl) do
- sh "cd src;erl -pa ../ebin -make"
- end
-
-task :test_beams => %w(ebin_tests) do
- sh "cd tests;erl -pa ../ebin -make"
- end
-
-# create directories
-task :ebin do mkdir "ebin" end
-task :priv do mkdir "priv" end
-task :ebin_tests do mkdir "ebin_tests" end
-
-def mkdir(dir)
- File.exist?(dir) || sh("mkdir #{dir}")
-end
-
-
-# Test suite
-task :test => %w(build test_beams) do
- erl_eval 'test_suite:test()', 'ebin', 'ebin_tests', 'ebin_tests/examples'
-end
-
-# Cleaning
-CLEAN.include %w(ebin ebin_tests src/neotoma_parse.erl priv/peg_includes.hrl)
-
-#---- generic erlang version tests ------
-
-# Returns the installed Erlang version
-def erlang_version
- version = `erl -version 2>&1`.strip.match(/\d\.\d(\.\d)?$/)
- unless version
- STDERR.puts "Error retrieving Erlang version. Do you have it installed?"
- exit 1
- end
-
- version[0]
-end
-
-# Evaluate the given Erlang statement
-def erl_eval(cmd, *pa)
- pa_str = pa.empty? ? "" : "-pa #{pa.join(' ')}"
- sh "erl -noshell #{pa_str} -eval '#{cmd}' -s erlang halt"
-end
-
-# Ensure the version of Erlang installed is recent enough
-task :check_erl_version do
- print "Checking Erlang version... "
- version = erlang_version
-
- if version >= "5.6.3"
- puts "#{version} (ok)"
- else
- puts "#{version} (too old)"
- puts "Sorry, the version of Erlang you have installed is too old to run Reia"
- puts "Reia requires a minimum Erlang version of R12B-3 (5.6.3)"
- puts "Please see http://wiki.reia-lang.org/wiki/Building#Prerequisites"
- exit 1
- end
-end
-
-
View
1  ebin/neotoma.app → src/neotoma.app.src
@@ -2,7 +2,6 @@
[
{description, "PEG/Packrat toolkit and parser-generator."},
{vsn, "1.5"},
- {modules, [neotoma, neotoma_parse, neotoma_peg]},
{applications, [kernel, stdlib]}
]
}.
View
66 test/test_combinators.erl
@@ -2,52 +2,52 @@
-author("Sean Cribbs <seancribbs@gmail.com>").
-include_lib("eunit/include/eunit.hrl").
-% Test the parser-combinators in the 'neotoma_peg' module
+% Test the parser-combinators in the 'peg_includes' module
-define(STARTINDEX, {{line,1},{column,1}}).
eof_test_() ->
[
- ?_assertEqual({fail,{expected,eof,?STARTINDEX}}, (neotoma_peg:p_eof())(<<"abc">>,?STARTINDEX)),
- ?_assertEqual({eof, [], ?STARTINDEX}, (neotoma_peg:p_eof())(<<>>,?STARTINDEX))
+ ?_assertEqual({fail,{expected,eof,?STARTINDEX}}, (peg_includes:p_eof())(<<"abc">>,?STARTINDEX)),
+ ?_assertEqual({eof, [], ?STARTINDEX}, (peg_includes:p_eof())(<<>>,?STARTINDEX))
].
optional_test_() ->
[
- ?_assertEqual({[], <<"xyz">>,?STARTINDEX}, (neotoma_peg:p_optional(neotoma_peg:p_string(<<"abc">>)))(<<"xyz">>,?STARTINDEX)),
- ?_assertEqual({<<"abc">>, <<"xyz">>,{{line,1},{column,4}}}, (neotoma_peg:p_optional(neotoma_peg:p_string(<<"abc">>)))(<<"abcxyz">>,?STARTINDEX))
+ ?_assertEqual({[], <<"xyz">>,?STARTINDEX}, (peg_includes:p_optional(peg_includes:p_string(<<"abc">>)))(<<"xyz">>,?STARTINDEX)),
+ ?_assertEqual({<<"abc">>, <<"xyz">>,{{line,1},{column,4}}}, (peg_includes:p_optional(peg_includes:p_string(<<"abc">>)))(<<"abcxyz">>,?STARTINDEX))
].
not_test_() ->
[
- ?_assertEqual({[], <<"xyzabc">>,?STARTINDEX}, (neotoma_peg:p_not(neotoma_peg:p_string(<<"abc">>)))(<<"xyzabc">>,?STARTINDEX)),
- ?_assertEqual({fail,{expected, {no_match, <<"abc">>}, ?STARTINDEX}}, (neotoma_peg:p_not(neotoma_peg:p_string(<<"abc">>)))(<<"abcxyz">>,?STARTINDEX))
+ ?_assertEqual({[], <<"xyzabc">>,?STARTINDEX}, (peg_includes:p_not(peg_includes:p_string(<<"abc">>)))(<<"xyzabc">>,?STARTINDEX)),
+ ?_assertEqual({fail,{expected, {no_match, <<"abc">>}, ?STARTINDEX}}, (peg_includes:p_not(peg_includes:p_string(<<"abc">>)))(<<"abcxyz">>,?STARTINDEX))
].
assert_test_() ->
[
- ?_assertEqual({fail,{expected, {string, <<"abc">>}, ?STARTINDEX}}, (neotoma_peg:p_assert(neotoma_peg:p_string(<<"abc">>)))(<<"xyzabc">>,?STARTINDEX)),
- ?_assertEqual({[], <<"abcxyz">>,?STARTINDEX}, (neotoma_peg:p_assert(neotoma_peg:p_string(<<"abc">>)))(<<"abcxyz">>,?STARTINDEX))
+ ?_assertEqual({fail,{expected, {string, <<"abc">>}, ?STARTINDEX}}, (peg_includes:p_assert(peg_includes:p_string(<<"abc">>)))(<<"xyzabc">>,?STARTINDEX)),
+ ?_assertEqual({[], <<"abcxyz">>,?STARTINDEX}, (peg_includes:p_assert(peg_includes:p_string(<<"abc">>)))(<<"abcxyz">>,?STARTINDEX))
].
seq_test_() ->
[
- ?_assertEqual({[<<"abc">>,<<"def">>], <<"xyz">>,{{line,1},{column,7}}}, (neotoma_peg:p_seq([neotoma_peg:p_string(<<"abc">>), neotoma_peg:p_string(<<"def">>)]))(<<"abcdefxyz">>,?STARTINDEX)),
- ?_assertEqual({fail,{expected, {string, <<"def">>}, {{line,1},{column,4}}}}, (neotoma_peg:p_seq([neotoma_peg:p_string(<<"abc">>), neotoma_peg:p_string(<<"def">>)]))(<<"abcxyz">>,?STARTINDEX))
+ ?_assertEqual({[<<"abc">>,<<"def">>], <<"xyz">>,{{line,1},{column,7}}}, (peg_includes:p_seq([peg_includes:p_string(<<"abc">>), peg_includes:p_string(<<"def">>)]))(<<"abcdefxyz">>,?STARTINDEX)),
+ ?_assertEqual({fail,{expected, {string, <<"def">>}, {{line,1},{column,4}}}}, (peg_includes:p_seq([peg_includes:p_string(<<"abc">>), peg_includes:p_string(<<"def">>)]))(<<"abcxyz">>,?STARTINDEX))
].
choose_test_() ->
[
- ?_assertEqual({<<"abc">>, <<"xyz">>, {{line,1},{column,4}}}, (neotoma_peg:p_choose([neotoma_peg:p_string(<<"abc">>), neotoma_peg:p_string(<<"def">>)]))(<<"abcxyz">>,?STARTINDEX)),
- ?_assertEqual({<<"def">>, <<"xyz">>, {{line,1},{column,4}}}, (neotoma_peg:p_choose([neotoma_peg:p_string(<<"abc">>), neotoma_peg:p_string(<<"def">>)]))(<<"defxyz">>,?STARTINDEX)),
- ?_assertEqual({<<"xyz">>, <<"xyz">>, {{line,1},{column,4}}}, (neotoma_peg:p_choose([neotoma_peg:p_string(<<"abc">>), neotoma_peg:p_string(<<"def">>), neotoma_peg:p_string(<<"xyz">>)]))(<<"xyzxyz">>,?STARTINDEX)),
- ?_assertEqual({fail,{expected,{string,<<"abc">>},?STARTINDEX}}, (neotoma_peg:p_choose([neotoma_peg:p_string(<<"abc">>),neotoma_peg:p_string(<<"def">>)]))(<<"xyz">>, ?STARTINDEX))
+ ?_assertEqual({<<"abc">>, <<"xyz">>, {{line,1},{column,4}}}, (peg_includes:p_choose([peg_includes:p_string(<<"abc">>), peg_includes:p_string(<<"def">>)]))(<<"abcxyz">>,?STARTINDEX)),
+ ?_assertEqual({<<"def">>, <<"xyz">>, {{line,1},{column,4}}}, (peg_includes:p_choose([peg_includes:p_string(<<"abc">>), peg_includes:p_string(<<"def">>)]))(<<"defxyz">>,?STARTINDEX)),
+ ?_assertEqual({<<"xyz">>, <<"xyz">>, {{line,1},{column,4}}}, (peg_includes:p_choose([peg_includes:p_string(<<"abc">>), peg_includes:p_string(<<"def">>), peg_includes:p_string(<<"xyz">>)]))(<<"xyzxyz">>,?STARTINDEX)),
+ ?_assertEqual({fail,{expected,{string,<<"abc">>},?STARTINDEX}}, (peg_includes:p_choose([peg_includes:p_string(<<"abc">>),peg_includes:p_string(<<"def">>)]))(<<"xyz">>, ?STARTINDEX))
].
zero_or_more_test_() ->
[
- ?_assertEqual({[], <<>>, ?STARTINDEX}, (neotoma_peg:p_zero_or_more(neotoma_peg:p_string(<<"abc">>)))(<<"">>,?STARTINDEX)),
- ?_assertEqual({[], <<"def">>,?STARTINDEX}, (neotoma_peg:p_zero_or_more(neotoma_peg:p_string(<<"abc">>)))(<<"def">>,?STARTINDEX)),
- ?_assertEqual({[<<"abc">>], <<"def">>,{{line,1},{column,4}}}, (neotoma_peg:p_zero_or_more(neotoma_peg:p_string(<<"abc">>)))(<<"abcdef">>,?STARTINDEX)),
- ?_assertEqual({[<<"abc">>, <<"abc">>], <<"def">>,{{line,1},{column,7}}}, (neotoma_peg:p_zero_or_more(neotoma_peg:p_string(<<"abc">>)))(<<"abcabcdef">>,?STARTINDEX))
+ ?_assertEqual({[], <<>>, ?STARTINDEX}, (peg_includes:p_zero_or_more(peg_includes:p_string(<<"abc">>)))(<<"">>,?STARTINDEX)),
+ ?_assertEqual({[], <<"def">>,?STARTINDEX}, (peg_includes:p_zero_or_more(peg_includes:p_string(<<"abc">>)))(<<"def">>,?STARTINDEX)),
+ ?_assertEqual({[<<"abc">>], <<"def">>,{{line,1},{column,4}}}, (peg_includes:p_zero_or_more(peg_includes:p_string(<<"abc">>)))(<<"abcdef">>,?STARTINDEX)),
+ ?_assertEqual({[<<"abc">>, <<"abc">>], <<"def">>,{{line,1},{column,7}}}, (peg_includes:p_zero_or_more(peg_includes:p_string(<<"abc">>)))(<<"abcabcdef">>,?STARTINDEX))
].
one_or_more_test_() ->
@@ -55,39 +55,39 @@ one_or_more_test_() ->
?_assertEqual({fail,{expected,
{at_least_one,
{string, <<"abc">>}
- }, ?STARTINDEX}}, (neotoma_peg:p_one_or_more(neotoma_peg:p_string(<<"abc">>)))(<<"def">>,?STARTINDEX)),
- ?_assertEqual({[<<"abc">>], <<"def">>,{{line,1},{column,4}}}, (neotoma_peg:p_one_or_more(neotoma_peg:p_string(<<"abc">>)))(<<"abcdef">>,?STARTINDEX)),
- ?_assertEqual({[<<"abc">>,<<"abc">>], <<"def">>,{{line,1},{column,7}}}, (neotoma_peg:p_one_or_more(neotoma_peg:p_string(<<"abc">>)))(<<"abcabcdef">>,?STARTINDEX))
+ }, ?STARTINDEX}}, (peg_includes:p_one_or_more(peg_includes:p_string(<<"abc">>)))(<<"def">>,?STARTINDEX)),
+ ?_assertEqual({[<<"abc">>], <<"def">>,{{line,1},{column,4}}}, (peg_includes:p_one_or_more(peg_includes:p_string(<<"abc">>)))(<<"abcdef">>,?STARTINDEX)),
+ ?_assertEqual({[<<"abc">>,<<"abc">>], <<"def">>,{{line,1},{column,7}}}, (peg_includes:p_one_or_more(peg_includes:p_string(<<"abc">>)))(<<"abcabcdef">>,?STARTINDEX))
].
label_test_() ->
[
- ?_assertEqual({fail,{expected, {string, <<"!">>}, ?STARTINDEX}}, (neotoma_peg:p_label(bang, neotoma_peg:p_string(<<"!">>)))(<<"?">>,?STARTINDEX)),
- ?_assertEqual({{bang, <<"!">>}, <<"">>,{{line,1},{column,2}}}, (neotoma_peg:p_label(bang, neotoma_peg:p_string(<<"!">>)))(<<"!">>,?STARTINDEX))
+ ?_assertEqual({fail,{expected, {string, <<"!">>}, ?STARTINDEX}}, (peg_includes:p_label(bang, peg_includes:p_string(<<"!">>)))(<<"?">>,?STARTINDEX)),
+ ?_assertEqual({{bang, <<"!">>}, <<"">>,{{line,1},{column,2}}}, (peg_includes:p_label(bang, peg_includes:p_string(<<"!">>)))(<<"!">>,?STARTINDEX))
].
string_test_() ->
[
- ?_assertEqual({<<"abc">>, <<"def">>,{{line,1},{column,4}}}, (neotoma_peg:p_string(<<"abc">>))(<<"abcdef">>,?STARTINDEX)),
- ?_assertEqual({fail,{expected, {string, <<"abc">>}, ?STARTINDEX}}, (neotoma_peg:p_string(<<"abc">>))(<<"defabc">>,?STARTINDEX))
+ ?_assertEqual({<<"abc">>, <<"def">>,{{line,1},{column,4}}}, (peg_includes:p_string(<<"abc">>))(<<"abcdef">>,?STARTINDEX)),
+ ?_assertEqual({fail,{expected, {string, <<"abc">>}, ?STARTINDEX}}, (peg_includes:p_string(<<"abc">>))(<<"defabc">>,?STARTINDEX))
].
anything_test_() ->
[
- ?_assertEqual({<<"a">>,<<"bcde">>,{{line,1},{column,2}}}, (neotoma_peg:p_anything())(<<"abcde">>,?STARTINDEX)),
- ?_assertEqual({<<"\n">>,<<"bcde">>,{{line,2},{column,1}}}, (neotoma_peg:p_anything())(<<"\nbcde">>,?STARTINDEX)),
- ?_assertEqual({fail,{expected, any_character, ?STARTINDEX}}, (neotoma_peg:p_anything())(<<"">>,?STARTINDEX))
+ ?_assertEqual({<<"a">>,<<"bcde">>,{{line,1},{column,2}}}, (peg_includes:p_anything())(<<"abcde">>,?STARTINDEX)),
+ ?_assertEqual({<<"\n">>,<<"bcde">>,{{line,2},{column,1}}}, (peg_includes:p_anything())(<<"\nbcde">>,?STARTINDEX)),
+ ?_assertEqual({fail,{expected, any_character, ?STARTINDEX}}, (peg_includes:p_anything())(<<"">>,?STARTINDEX))
].
charclass_test_() ->
[
- ?_assertEqual({<<"+">>,<<"----">>,{{line,1},{column,2}}}, (neotoma_peg:p_charclass(<<"[+]">>))(<<"+----">>,?STARTINDEX)),
- ?_assertEqual({fail,{expected, {character_class, <<"[+]">>}, ?STARTINDEX}}, (neotoma_peg:p_charclass(<<"[+]">>))(<<"----">>,?STARTINDEX))
+ ?_assertEqual({<<"+">>,<<"----">>,{{line,1},{column,2}}}, (peg_includes:p_charclass(<<"[+]">>))(<<"+----">>,?STARTINDEX)),
+ ?_assertEqual({fail,{expected, {character_class, "[+]"}, ?STARTINDEX}}, (peg_includes:p_charclass(<<"[+]">>))(<<"----">>,?STARTINDEX))
].
line_test() ->
- ?assertEqual(1, neotoma_peg:line({{line,1},{column,2}})).
+ ?assertEqual(1, peg_includes:line({{line,1},{column,2}})).
column_test() ->
- ?assertEqual(2, neotoma_peg:column({{line,1},{column,2}})).
+ ?assertEqual(2, peg_includes:column({{line,1},{column,2}})).
View
93 tests/test_combinators.erl
@@ -1,93 +0,0 @@
--module(test_combinators).
--author("Sean Cribbs <seancribbs@gmail.com>").
--include_lib("eunit/include/eunit.hrl").
-
-% Test the parser-combinators in the 'peg_includes' module
--define(STARTINDEX, {{line,1},{column,1}}).
-eof_test_() ->
- [
- ?_assertEqual({fail,{expected,eof,?STARTINDEX}}, (peg_includes:p_eof())(<<"abc">>,?STARTINDEX)),
- ?_assertEqual({eof, [], ?STARTINDEX}, (peg_includes:p_eof())(<<>>,?STARTINDEX))
- ].
-
-optional_test_() ->
- [
- ?_assertEqual({[], <<"xyz">>,?STARTINDEX}, (peg_includes:p_optional(peg_includes:p_string(<<"abc">>)))(<<"xyz">>,?STARTINDEX)),
- ?_assertEqual({<<"abc">>, <<"xyz">>,{{line,1},{column,4}}}, (peg_includes:p_optional(peg_includes:p_string(<<"abc">>)))(<<"abcxyz">>,?STARTINDEX))
- ].
-
-not_test_() ->
- [
- ?_assertEqual({[], <<"xyzabc">>,?STARTINDEX}, (peg_includes:p_not(peg_includes:p_string(<<"abc">>)))(<<"xyzabc">>,?STARTINDEX)),
- ?_assertEqual({fail,{expected, {no_match, <<"abc">>}, ?STARTINDEX}}, (peg_includes:p_not(peg_includes:p_string(<<"abc">>)))(<<"abcxyz">>,?STARTINDEX))
- ].
-
-assert_test_() ->
- [
- ?_assertEqual({fail,{expected, {string, <<"abc">>}, ?STARTINDEX}}, (peg_includes:p_assert(peg_includes:p_string(<<"abc">>)))(<<"xyzabc">>,?STARTINDEX)),
- ?_assertEqual({[], <<"abcxyz">>,?STARTINDEX}, (peg_includes:p_assert(peg_includes:p_string(<<"abc">>)))(<<"abcxyz">>,?STARTINDEX))
- ].
-
-seq_test_() ->
- [
- ?_assertEqual({[<<"abc">>,<<"def">>], <<"xyz">>,{{line,1},{column,7}}}, (peg_includes:p_seq([peg_includes:p_string(<<"abc">>), peg_includes:p_string(<<"def">>)]))(<<"abcdefxyz">>,?STARTINDEX)),
- ?_assertEqual({fail,{expected, {string, <<"def">>}, {{line,1},{column,4}}}}, (peg_includes:p_seq([peg_includes:p_string(<<"abc">>), peg_includes:p_string(<<"def">>)]))(<<"abcxyz">>,?STARTINDEX))
- ].
-
-choose_test_() ->
- [
- ?_assertEqual({<<"abc">>, <<"xyz">>, {{line,1},{column,4}}}, (peg_includes:p_choose([peg_includes:p_string(<<"abc">>), peg_includes:p_string(<<"def">>)]))(<<"abcxyz">>,?STARTINDEX)),
- ?_assertEqual({<<"def">>, <<"xyz">>, {{line,1},{column,4}}}, (peg_includes:p_choose([peg_includes:p_string(<<"abc">>), peg_includes:p_string(<<"def">>)]))(<<"defxyz">>,?STARTINDEX)),
- ?_assertEqual({<<"xyz">>, <<"xyz">>, {{line,1},{column,4}}}, (peg_includes:p_choose([peg_includes:p_string(<<"abc">>), peg_includes:p_string(<<"def">>), peg_includes:p_string(<<"xyz">>)]))(<<"xyzxyz">>,?STARTINDEX)),
- ?_assertEqual({fail,{expected,{string,<<"abc">>},?STARTINDEX}}, (peg_includes:p_choose([peg_includes:p_string(<<"abc">>),peg_includes:p_string(<<"def">>)]))(<<"xyz">>, ?STARTINDEX))
- ].
-
-zero_or_more_test_() ->
- [
- ?_assertEqual({[], <<>>, ?STARTINDEX}, (peg_includes:p_zero_or_more(peg_includes:p_string(<<"abc">>)))(<<"">>,?STARTINDEX)),
- ?_assertEqual({[], <<"def">>,?STARTINDEX}, (peg_includes:p_zero_or_more(peg_includes:p_string(<<"abc">>)))(<<"def">>,?STARTINDEX)),
- ?_assertEqual({[<<"abc">>], <<"def">>,{{line,1},{column,4}}}, (peg_includes:p_zero_or_more(peg_includes:p_string(<<"abc">>)))(<<"abcdef">>,?STARTINDEX)),
- ?_assertEqual({[<<"abc">>, <<"abc">>], <<"def">>,{{line,1},{column,7}}}, (peg_includes:p_zero_or_more(peg_includes:p_string(<<"abc">>)))(<<"abcabcdef">>,?STARTINDEX))
- ].
-
-one_or_more_test_() ->
- [
- ?_assertEqual({fail,{expected,
- {at_least_one,
- {string, <<"abc">>}
- }, ?STARTINDEX}}, (peg_includes:p_one_or_more(peg_includes:p_string(<<"abc">>)))(<<"def">>,?STARTINDEX)),
- ?_assertEqual({[<<"abc">>], <<"def">>,{{line,1},{column,4}}}, (peg_includes:p_one_or_more(peg_includes:p_string(<<"abc">>)))(<<"abcdef">>,?STARTINDEX)),
- ?_assertEqual({[<<"abc">>,<<"abc">>], <<"def">>,{{line,1},{column,7}}}, (peg_includes:p_one_or_more(peg_includes:p_string(<<"abc">>)))(<<"abcabcdef">>,?STARTINDEX))
- ].
-
-label_test_() ->
- [
- ?_assertEqual({fail,{expected, {string, <<"!">>}, ?STARTINDEX}}, (peg_includes:p_label(bang, peg_includes:p_string(<<"!">>)))(<<"?">>,?STARTINDEX)),
- ?_assertEqual({{bang, <<"!">>}, <<"">>,{{line,1},{column,2}}}, (peg_includes:p_label(bang, peg_includes:p_string(<<"!">>)))(<<"!">>,?STARTINDEX))
- ].
-
-string_test_() ->
- [
- ?_assertEqual({<<"abc">>, <<"def">>,{{line,1},{column,4}}}, (peg_includes:p_string(<<"abc">>))(<<"abcdef">>,?STARTINDEX)),
- ?_assertEqual({fail,{expected, {string, <<"abc">>}, ?STARTINDEX}}, (peg_includes:p_string(<<"abc">>))(<<"defabc">>,?STARTINDEX))
- ].
-
-anything_test_() ->
- [
- ?_assertEqual({<<"a">>,<<"bcde">>,{{line,1},{column,2}}}, (peg_includes:p_anything())(<<"abcde">>,?STARTINDEX)),
- ?_assertEqual({<<"\n">>,<<"bcde">>,{{line,2},{column,1}}}, (peg_includes:p_anything())(<<"\nbcde">>,?STARTINDEX)),
- ?_assertEqual({fail,{expected, any_character, ?STARTINDEX}}, (peg_includes:p_anything())(<<"">>,?STARTINDEX))
- ].
-
-charclass_test_() ->
- [
- ?_assertEqual({<<"+">>,<<"----">>,{{line,1},{column,2}}}, (peg_includes:p_charclass(<<"[+]">>))(<<"+----">>,?STARTINDEX)),
- ?_assertEqual({fail,{expected, {character_class, "[+]"}, ?STARTINDEX}}, (peg_includes:p_charclass(<<"[+]">>))(<<"----">>,?STARTINDEX))
- ].
-
-line_test() ->
- ?assertEqual(1, peg_includes:line({{line,1},{column,2}})).
-
-column_test() ->
- ?assertEqual(2, peg_includes:column({{line,1},{column,2}})).
-
Please sign in to comment.
Something went wrong with that request. Please try again.