Skip to content

Commit

Permalink
Merge pull request #243 from Yelp/default_no_auto_self
Browse files Browse the repository at this point in the history
Default enable_auto_self to False
  • Loading branch information
Buck Evan committed Jun 15, 2016
2 parents 564d310 + bc43d0a commit e2efa8b
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 61 deletions.
2 changes: 1 addition & 1 deletion Cheetah/legacy_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
# All #import statements are hoisted to the top of the module
'useLegacyImportMode': True,
# Can $foo mean both self.foo and NS['foo']?
'enable_auto_self': True,
'enable_auto_self': False,
}

CLASS_NAME = 'YelpCheetahTemplate'
Expand Down
2 changes: 1 addition & 1 deletion testing/templates/src/super_base.tmpl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$foo() $bar(99) $another_def(20)
$self.foo() $self.bar(99) $self.another_def(20)
#def foo(): this is base foo
#def bar(arg): super-$arg
#def another_def(arg): super-$arg
2 changes: 1 addition & 1 deletion testing/templates/src/super_child.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#super
This is child foo
#super()
$bar(1234)
$self.bar(1234)
#end def
#def bar(arg): #super(arg=arg)
#def another_def(arg): #super(arg)
6 changes: 3 additions & 3 deletions tests/Compiler_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def test_comments():

def test_optimized_builtins():
src = compile_source('$int("9001")')
# Instead of _v = VFFSL("int"...
# Instead of _v = VFFNS("int"...
assert ' _v = int("9001") #' in src


Expand All @@ -57,7 +57,7 @@ def test_optimized_attributes_of_builtins_function_args():

def test_non_optimized_searchlist():
src = compile_source('$int($foo)')
assert ' _v = int(VFFSL("foo"' in src
assert ' _v = int(VFFNS("foo"' in src


def test_optimization_still_prefers_locals():
Expand Down Expand Up @@ -181,7 +181,7 @@ class fooobj(object):
def test_optimization_removes_VFN():
src = compile_source(VFN_opt_src)
assert 'VFN(' not in src
assert ' _v = VFFSL("foo", locals(), globals(), self, NS).barvar[0].upper() #' in src
assert ' _v = VFFNS("foo", locals(), globals(), NS).barvar[0].upper() #' in src
cls = compile_to_class(VFN_opt_src)
assert cls({'foo': fooobj}).respond() == 'W'

Expand Down

0 comments on commit e2efa8b

Please sign in to comment.