Greg Hurrell [Mon, 20 Oct 2014 03:51:28 +0000 (20:51 -0700)]
Update Rspec syntax
Did this with the help of the transpec gem. Contrary to the README, I
found I did need to add it to the Gemfile (although obviously, I removed
it immediately afterwards).
Additionally it crashed trying to open `.git/COMMIT_EDITMSG` after the
conversion had completed, because I was running it from inside a
submodule; upstream issue for that:
Greg Hurrell [Sun, 19 Oct 2014 21:15:01 +0000 (14:15 -0700)]
Update to RSpec 3.1.0
Surprisingly, little broke in the move from 1.3.0 to 3.1.0. Changes
included:
- simplify `require 'spec_helper'` statements
- kill some old lambdas
- change `expect`/`should` assertions to `expect`/`to`
- updates for new mock API
- update binstubs
- drop explicit `require 'rubygems'` from spec helper; we'll always run
using `bin/rspec`
- tweak `pending` examples, as RSpec now complains if they have a block
which doesn't raise an error
Note, we're still mostly using the deprecated `should` syntax. I'll
leave the move to `expect` for another moment.
Wincent Colaiuta [Fri, 27 Aug 2010 21:37:40 +0000 (23:37 +0200)]
Remove :origin option from memoization identifier
This was a Walrus-specific option so really has no place in Walrat
itself, and it turns out that it isn't necessary anyway and so only is a
waste of memory.
The motivation for adding it to the memoization identifier was so as to
distinguish between parse results with the same parseable at the same
location but in different files (for example, a comment directive
parslet seeing a comment on the first line of a file and also on the
first line of a file included from the former).
It turns out that this kind of differentiation is never needed because
include files are parsed by a completely separate Parser instance, and
each instance has its own MemoizingCache instance. See the
Walrus::Grammar :include_subparslet rule, and particularly this line:
Wincent Colaiuta [Fri, 27 Aug 2010 16:17:14 +0000 (18:17 +0200)]
Call to_parseable before storing rules
Given a rule like:
rule :foo, 'bar'
We previously stored the string literal in the rules hash. At parse
time, these rules get accessed via the SymbolParslet class, which
does:
result = grammar.rules[@symbol].memoizing_parse(...)
The memoizing_parse method itself calls to_parseable on the rule,
which means that every time we evaluate a rule like :foo we end up
creating a new StringParslet instance.
By storing 'bar'.to_parseable in the rules hash instead we avoid
the unnecessary object creation. With this change each time
memoizing_parse calls to_parseable on the stored value, the same
instance is returned and no new object is created, thus reducing memory
use.