Skip to content

Commit

Permalink
Merge pull request #3202 from masatake/rspec--rewrite
Browse files Browse the repository at this point in the history
RSpec: rewrite in C language
  • Loading branch information
masatake committed Dec 19, 2021
2 parents 2d0dda9 + 1b09ed7 commit 05e6ab4
Show file tree
Hide file tree
Showing 23 changed files with 447 additions and 179 deletions.
2 changes: 2 additions & 0 deletions Units/parser-rspec.r/broken-input.d/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This csae is for observing the behavior of the parser when a broken
input file is given.
2 changes: 2 additions & 0 deletions Units/parser-rspec.r/broken-input.d/args.ctags
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--fields=+Klen
--sort=no
7 changes: 7 additions & 0 deletions Units/parser-rspec.r/broken-input.d/input.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
RSpec.describe Order do
context "with no items do
it "behaves one way" do
# ...
end
end
end
2 changes: 2 additions & 0 deletions Units/parser-rspec.r/simple-rspec.d/args.ctags
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--fields=+Klen
--sort=no
9 changes: 9 additions & 0 deletions Units/parser-rspec.r/simple-rspec.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Order input.rb /^RSpec.describe Order do$/;" describe line:6 language:RSpec end:18
with no items input.rb /^ context "with no items" do$/;" context line:7 language:RSpec describe:Order end:11
with one item input.rb /^ context "with one item" do$/;" context line:13 language:RSpec describe:Order end:17
Calculator input.rb /^RSpec.describe Calculator do$/;" describe line:20 language:RSpec end:26
#add input.rb /^ describe '#add' do$/;" describe line:21 language:RSpec describe:Calculator end:25
Core input.rb /^module RSpec::Core$/;" module line:29 language:Ruby module:RSpec end:48
ExampleGroup input.rb /^ RSpec.describe ExampleGroup do$/;" describe line:30 language:RSpec end:47
when calling `#{method}`, an example group API, from within an example input.rb /^ context "when calling `#{method}`, an example group API, from within an example" do$/;" context line:32 language:RSpec describe:ExampleGroup end:42
Object describing nested example_groups input.rb /^ describe Object, "describing nested example_groups", :little_less_nested => 'yep' do$/;" describe line:45 language:RSpec describe:ExampleGroup end:46
48 changes: 48 additions & 0 deletions Units/parser-rspec.r/simple-rspec.d/input.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#
# Randomly taken from https://github.com/rspec/rspec-core
# https://github.com/rspec/rspec-core/blob/master/LICENSE.md
#

RSpec.describe Order do
context "with no items" do
it "behaves one way" do
# ...
end
end

context "with one item" do
it "behaves another way" do
# ...
end
end
end

RSpec.describe Calculator do
describe '#add' do
it 'returns the sum of its arguments' do
expect(Calculator.new.add(1, 2)).to eq(3)
end
end
end

# Taken from rspec-core/spec/rspec/core/example_group_spec.rb
module RSpec::Core
RSpec.describe ExampleGroup do
%w[ describe context let before it it_behaves_like ].each do |method|
context "when calling `#{method}`, an example group API, from within an example" do
it "tells the user they are in the wrong scope for that API" do
ex = nil

RSpec.describe do
ex = example { __send__(method, "foo") }
end.run

expect(ex).to fail_with(ExampleGroup::WrongScopeError)
end
end
end

describe Object, "describing nested example_groups", :little_less_nested => 'yep' do
end
end
end
2 changes: 0 additions & 2 deletions Units/simple-rspec.d/args.ctags

This file was deleted.

5 changes: 0 additions & 5 deletions Units/simple-rspec.d/expected.tags

This file was deleted.

26 changes: 0 additions & 26 deletions Units/simple-rspec.d/input.rb

This file was deleted.

2 changes: 1 addition & 1 deletion docs/news.rst
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ The following parsers have been added:
* Robot
* RpmMacros *optlib*
* RpmSpec
* RSpec *optlib*
* RSpec *Ruby based subparser*
* Rust
* S4Class *R based subparser*
* SCSS *optlib*
Expand Down
4 changes: 2 additions & 2 deletions main/entry.c
Original file line number Diff line number Diff line change
Expand Up @@ -1546,7 +1546,7 @@ static void writeTagEntry (const tagEntryInfo *const tag)

if (includeExtensionFlags ()
&& isXtagEnabled (XTAG_QUALIFIED_TAGS)
&& doesInputLanguageRequestAutomaticFQTag ()
&& doesInputLanguageRequestAutomaticFQTag (tag)
&& !isTagExtraBitMarked (tag, XTAG_QUALIFIED_TAGS)
&& !tag->skipAutoFQEmission)
{
Expand Down Expand Up @@ -1616,7 +1616,7 @@ extern void uncorkTagFile(void)

writeTagEntry (tag);

if (doesInputLanguageRequestAutomaticFQTag ()
if (doesInputLanguageRequestAutomaticFQTag (tag)
&& isXtagEnabled (XTAG_QUALIFIED_TAGS)
&& !isTagExtraBitMarked (tag, XTAG_QUALIFIED_TAGS)
&& !tag->skipAutoFQEmission
Expand Down
4 changes: 2 additions & 2 deletions main/read.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,9 @@ extern bool doesInputLanguageAllowNullTag (void)
return doesLanguageAllowNullTag (getInputLanguage ());
}

extern bool doesInputLanguageRequestAutomaticFQTag (void)
extern bool doesInputLanguageRequestAutomaticFQTag (const tagEntryInfo *e)
{
return doesLanguageRequestAutomaticFQTag (getInputLanguage ());
return doesLanguageRequestAutomaticFQTag (e->langType);
}

extern const char *getSourceFileTagPath (void)
Expand Down
2 changes: 1 addition & 1 deletion main/read_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ extern unsigned int countInputLanguageKinds (void);
extern unsigned int countInputLanguageRoles (int kindIndex);

extern bool doesInputLanguageAllowNullTag (void);
extern bool doesInputLanguageRequestAutomaticFQTag (void);
extern bool doesInputLanguageRequestAutomaticFQTag (const tagEntryInfo *e);
extern bool doesParserRunAsGuest (void);
extern bool doesSubparserRun (void);
extern langType getLanguageForBaseParser (void);
Expand Down
78 changes: 0 additions & 78 deletions optlib/RSpec.c

This file was deleted.

40 changes: 0 additions & 40 deletions optlib/RSpec.ctags

This file was deleted.

2 changes: 1 addition & 1 deletion parsers/itcl.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ static void inputStart (subparser *s)
itcl->foundITclNamespaceImported = itclForceUse;
}

struct itclSubparser itclSubparser = {
static struct itclSubparser itclSubparser = {
.tcl = {
.subparser = {
.direction = SUBPARSER_BI_DIRECTION,
Expand Down
1 change: 0 additions & 1 deletion parsers/ldscript.c
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,6 @@ extern parserDefinition* LdScriptParser (void)
def->aliases = aliases;
def->keywordTable = LdScriptKeywordTable;
def->keywordCount = ARRAY_SIZE (LdScriptKeywordTable);
def->initialize = initialize;
def->fieldTable = LdScriptFields;
def->fieldCount = ARRAY_SIZE (LdScriptFields);

Expand Down
Loading

0 comments on commit 05e6ab4

Please sign in to comment.