Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abargnesi/260c613ff3946367a4418fb2070392a5 to your computer and use it in GitHub Desktop.
Save abargnesi/260c613ff3946367a4418fb2070392a5 to your computer and use it in GitHub Desktop.
Patch to add failing partial identifier test.
diff --git a/spec/unit/language/version1/syntax/v1_syntax_spec.rb b/spec/unit/language/version1/syntax/v1_syntax_spec.rb
index 513d716..ad590c1 100644
--- a/spec/unit/language/version1/syntax/v1_syntax_spec.rb
+++ b/spec/unit/language/version1/syntax/v1_syntax_spec.rb
@@ -33,4 +33,18 @@ describe 'parsing' do
end
end
end
+
+ context 'partial' do
+ context 'identifiers' do
+ subject(:parser) { parsers::Common::Identifier }
+
+ it 'results in an incomplete identifier with partial value' do
+ output = parse_ast(parser, random_partial_identifier)
+ expect(output).to be_a(ast::Identifier)
+ expect(output).to respond_to(:complete)
+ expect(output.complete).to be(false)
+ expect(output.string_literal).to match(/[A-Za-z0-9_]+/)
+ end
+ end
+ end
end
diff --git a/spec/unit/spec_helper.rb b/spec/unit/spec_helper.rb
index 4273953..e2cd705 100644
--- a/spec/unit/spec_helper.rb
+++ b/spec/unit/spec_helper.rb
@@ -13,6 +13,14 @@ def random_identifier
Rantly { sized(range(1, 50)) { string(/[A-Za-z0-9_]/) } }
end
+def random_partial_identifier
+ Rantly do
+ identifier = random_identifier
+ invalid_char = sized(1) { string(/[^0-9A-za-z_]/) }
+ identifier.insert(range(0, identifier.length - 1), invalid_char)
+ end
+end
+
def random_string(quoted = true)
Rantly do
value = sized(range(1, 50)) { string(:graph) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment