Skip to content

Commit

Permalink
doOnce fix addresses #150
Browse files Browse the repository at this point in the history
  • Loading branch information
davidedc committed Nov 23, 2014
1 parent 516eb33 commit ce1fccf
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
20 changes: 19 additions & 1 deletion coffee/languages/livelangv1/code-preprocessor-tests.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -1112,7 +1112,6 @@ define ['LiveLangV1/code-preprocessor-tests'], (foo) ->
box()
"""
,

input: """
rotate time/1000
doOnce
Expand All @@ -1129,6 +1128,25 @@ define ['LiveLangV1/code-preprocessor-tests'], (foo) ->
addDoOnce(4); 1.times ball
box()
"""
,
input: """
rotate time/1000
doOnce
▶// test
▶background 255
▶fill 255,0,0
✓doOnce -> ball
box
"""
expected: """
rotate time/1000
1.times ->
▶addDoOnce(1)
▶background 255
▶fill 255,0,0
noOperation
box()
"""
,
# note that the matrix operations do chain also
# in this case
Expand Down
3 changes: 2 additions & 1 deletion coffee/languages/livelangv1/code-preprocessor.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -319,9 +319,10 @@ define [
elaboratedSourceByLine[eachLine] =
elaboratedSourceByLine[eachLine].replace(
/(^|\s+)doOnce[ \t]*$/g, "$11.times ->")

elaboratedSourceByLine[eachLine + 1] =
elaboratedSourceByLine[eachLine + 1].replace(
/^(\s*)(.+)$/g, "$1addDoOnce(" + eachLine + "); $2")
/^(\s*)(.*)$/g, "$1addDoOnce(" + eachLine + "); $2")
code = elaboratedSourceByLine.join "\n"

#alert('soon after replacing doOnces'+code)
Expand Down

0 comments on commit ce1fccf

Please sign in to comment.