Skip to content

Commit 05e6ab4

Browse files
authored
Merge pull request #3202 from masatake/rspec--rewrite
RSpec: rewrite in C language
2 parents 2d0dda9 + 1b09ed7 commit 05e6ab4

File tree

23 files changed

+447
-179
lines changed

23 files changed

+447
-179
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
This csae is for observing the behavior of the parser when a broken
2+
input file is given.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
--fields=+Klen
2+
--sort=no
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
RSpec.describe Order do
2+
context "with no items do
3+
it "behaves one way" do
4+
# ...
5+
end
6+
end
7+
end
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
--fields=+Klen
2+
--sort=no
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Order input.rb /^RSpec.describe Order do$/;" describe line:6 language:RSpec end:18
2+
with no items input.rb /^ context "with no items" do$/;" context line:7 language:RSpec describe:Order end:11
3+
with one item input.rb /^ context "with one item" do$/;" context line:13 language:RSpec describe:Order end:17
4+
Calculator input.rb /^RSpec.describe Calculator do$/;" describe line:20 language:RSpec end:26
5+
#add input.rb /^ describe '#add' do$/;" describe line:21 language:RSpec describe:Calculator end:25
6+
Core input.rb /^module RSpec::Core$/;" module line:29 language:Ruby module:RSpec end:48
7+
ExampleGroup input.rb /^ RSpec.describe ExampleGroup do$/;" describe line:30 language:RSpec end:47
8+
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
9+
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
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#
2+
# Randomly taken from https://github.com/rspec/rspec-core
3+
# https://github.com/rspec/rspec-core/blob/master/LICENSE.md
4+
#
5+
6+
RSpec.describe Order do
7+
context "with no items" do
8+
it "behaves one way" do
9+
# ...
10+
end
11+
end
12+
13+
context "with one item" do
14+
it "behaves another way" do
15+
# ...
16+
end
17+
end
18+
end
19+
20+
RSpec.describe Calculator do
21+
describe '#add' do
22+
it 'returns the sum of its arguments' do
23+
expect(Calculator.new.add(1, 2)).to eq(3)
24+
end
25+
end
26+
end
27+
28+
# Taken from rspec-core/spec/rspec/core/example_group_spec.rb
29+
module RSpec::Core
30+
RSpec.describe ExampleGroup do
31+
%w[ describe context let before it it_behaves_like ].each do |method|
32+
context "when calling `#{method}`, an example group API, from within an example" do
33+
it "tells the user they are in the wrong scope for that API" do
34+
ex = nil
35+
36+
RSpec.describe do
37+
ex = example { __send__(method, "foo") }
38+
end.run
39+
40+
expect(ex).to fail_with(ExampleGroup::WrongScopeError)
41+
end
42+
end
43+
end
44+
45+
describe Object, "describing nested example_groups", :little_less_nested => 'yep' do
46+
end
47+
end
48+
end

Units/simple-rspec.d/args.ctags

Lines changed: 0 additions & 2 deletions
This file was deleted.

Units/simple-rspec.d/expected.tags

Lines changed: 0 additions & 5 deletions
This file was deleted.

Units/simple-rspec.d/input.rb

Lines changed: 0 additions & 26 deletions
This file was deleted.

docs/news.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ The following parsers have been added:
455455
* Robot
456456
* RpmMacros *optlib*
457457
* RpmSpec
458-
* RSpec *optlib*
458+
* RSpec *Ruby based subparser*
459459
* Rust
460460
* S4Class *R based subparser*
461461
* SCSS *optlib*

main/entry.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1546,7 +1546,7 @@ static void writeTagEntry (const tagEntryInfo *const tag)
15461546

15471547
if (includeExtensionFlags ()
15481548
&& isXtagEnabled (XTAG_QUALIFIED_TAGS)
1549-
&& doesInputLanguageRequestAutomaticFQTag ()
1549+
&& doesInputLanguageRequestAutomaticFQTag (tag)
15501550
&& !isTagExtraBitMarked (tag, XTAG_QUALIFIED_TAGS)
15511551
&& !tag->skipAutoFQEmission)
15521552
{
@@ -1616,7 +1616,7 @@ extern void uncorkTagFile(void)
16161616

16171617
writeTagEntry (tag);
16181618

1619-
if (doesInputLanguageRequestAutomaticFQTag ()
1619+
if (doesInputLanguageRequestAutomaticFQTag (tag)
16201620
&& isXtagEnabled (XTAG_QUALIFIED_TAGS)
16211621
&& !isTagExtraBitMarked (tag, XTAG_QUALIFIED_TAGS)
16221622
&& !tag->skipAutoFQEmission

main/read.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,9 @@ extern bool doesInputLanguageAllowNullTag (void)
245245
return doesLanguageAllowNullTag (getInputLanguage ());
246246
}
247247

248-
extern bool doesInputLanguageRequestAutomaticFQTag (void)
248+
extern bool doesInputLanguageRequestAutomaticFQTag (const tagEntryInfo *e)
249249
{
250-
return doesLanguageRequestAutomaticFQTag (getInputLanguage ());
250+
return doesLanguageRequestAutomaticFQTag (e->langType);
251251
}
252252

253253
extern const char *getSourceFileTagPath (void)

main/read_p.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ extern unsigned int countInputLanguageKinds (void);
4040
extern unsigned int countInputLanguageRoles (int kindIndex);
4141

4242
extern bool doesInputLanguageAllowNullTag (void);
43-
extern bool doesInputLanguageRequestAutomaticFQTag (void);
43+
extern bool doesInputLanguageRequestAutomaticFQTag (const tagEntryInfo *e);
4444
extern bool doesParserRunAsGuest (void);
4545
extern bool doesSubparserRun (void);
4646
extern langType getLanguageForBaseParser (void);

optlib/RSpec.c

Lines changed: 0 additions & 78 deletions
This file was deleted.

optlib/RSpec.ctags

Lines changed: 0 additions & 40 deletions
This file was deleted.

parsers/itcl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ static void inputStart (subparser *s)
283283
itcl->foundITclNamespaceImported = itclForceUse;
284284
}
285285

286-
struct itclSubparser itclSubparser = {
286+
static struct itclSubparser itclSubparser = {
287287
.tcl = {
288288
.subparser = {
289289
.direction = SUBPARSER_BI_DIRECTION,

parsers/ldscript.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,6 @@ extern parserDefinition* LdScriptParser (void)
760760
def->aliases = aliases;
761761
def->keywordTable = LdScriptKeywordTable;
762762
def->keywordCount = ARRAY_SIZE (LdScriptKeywordTable);
763-
def->initialize = initialize;
764763
def->fieldTable = LdScriptFields;
765764
def->fieldCount = ARRAY_SIZE (LdScriptFields);
766765

0 commit comments

Comments
 (0)