(PUP-1220) apply proper scoping rules to scope#to_hash

The fix for #1427 added an instance method to the scope class
for exporting all variables from the local scope. This method
apparently re-implemented the dynamic scoping rules.

When those were removed, the #to_hash method was left as was.
As a result, dynamic scoping still worked from within templates,
when using the @variable syntax in the erb code.

Fix this by using the new #enclosing_scope method so that proper
scoping rules are used instead.
(PUP-1220) make the dynamic scoping fix for #22800 flexible

As suggested by Henrik Lindberg, make the parser only behave correctly
when parser=future is configured. If working manifests rely on the
regression, the next point release won't break them. Instead, users can
test for this using the configuration setting.

The next major release should adopt the fix as standard behavior and
the legacy support should be removed. Since the variable lookups in
templates relies on the accessing of local attributes, there is no
way to issue deprecation warnings to users.
(PUP-1220) optimize template scoping fix

Following enhancements as suggested by Erik Dalen, Andy Parker et al.
* prefer Puppet[:parser] over Puppet['parser']
* cache the config value of Puppet[:parser]
* pick the future vs. legacy branch only once per template
(maint) Match current spec style and usage
(PUP-1765) Change assert_not_match to assert_no_match

I believe this is a minitest vrs test/unit ruby version issue.
'assert_no_match' is the variant available on all platforms that we use
throughout the suite.
Merge pull request #2117 from ffrank/ticket/master/22800-dynamic-lookup-in-templates

(PUP-1220) apply proper scoping rules to scope#to_hash
(PUP-1372) Add variable and pops type checks to defined function

The original Puppet::Parser::Functions defined() checked whether a class
or resource type had been defined, or a particular resource reference
declared.  We've extended this to allow for checking variable
assignment, by looking up a string reference for the variable name.

This version can also look up defined classes, types and resources by
type reference if the future parser is in effect.

Paired with Henrik Lindberg <henrik.lindberg@puppetlabs.com>
Merge pull request #2411 from jpartlow/feature/master/pup-1372-enhance-defined-function

Feature/master/pup 1372 enhance defined function
Merge branch 'master' of https://github.com/puppetlabs/puppet