Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for Expect and update Tickle #1084

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ Elvish
EmacsDevEnv
Emojicode
Erlang
Expect
Factor
FEN
Fish
Expand Down
12 changes: 9 additions & 3 deletions languages.json
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,12 @@
"line_comment": ["%"],
"extensions": ["erl", "hrl"]
},
"Expect": {
"name": "Expect",
"line_comment": [["#", ";#"]],
"quotes": [["\\\"", "\\\""]],
"extensions": ["exp"]
},
"Factor": {
"line_comment": ["!", "#!"],
"multi_line_comments": [["/*", "*/"]],
Expand Down Expand Up @@ -1434,9 +1440,9 @@
"extensions": ["sv", "svh"]
},
"Tcl": {
"name": "TCL",
"line_comment": ["#"],
"quotes": [["\\\"", "\\\""], ["'", "'"]],
"name": "Tcl",
"line_comment": [["#", ";#"]],
"quotes": [["\\\"", "\\\""]],
"extensions": ["tcl"]
},
"Tera": {
Expand Down
44 changes: 44 additions & 0 deletions tests/data/Expect.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# 44 lines 27 code 9 comments 10 blanks

##
# foo function doing stuff
#
proc foo {bar {baz 5} \
{not_used "hi mom"}} {
puts $bar ;# print out bar
# sum bar + baz
set foo_res [expr $bar + $baz]
return $foo_res
}

proc #weird {} {
return -code 5
}


puts "hello world ####"

puts #Alsovalid# ;# comment here!
puts {;#and this}
puts {really anything -$#;/ /\ \ -_'@?` "\".$?"!'][¨@ is allowed in curly braces}

puts "3 == [foo 1 2] and 6 == [foo 2]"

set function "#weird"
set code [catch {[$function]}]
puts "$code == 5"

# And now onto expect specific
spawn "bash" "-c" "sleep 2; echo regex_pattern"

set timeout 5 ;# this is 5 seconds
expect {
-re "regex_pattern" {
puts "and then this when it's found 'match' == $expect_out(0,string)"
}
timeout {
# if no match after 5 seconds
}
}

after 500
29 changes: 29 additions & 0 deletions tests/data/Tcl.tcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# 29 lines 17 code 6 comments 7 blanks

##
# foo function doing stuff
#
proc foo {bar {baz 5} \
{not_used "hi mom"}} {
puts $bar ;# print out bar
# sum bar + baz
set foo_res [expr $bar + $baz]
return $foo_res
}

proc #weird {} {
return -code 5
}


puts "hello world ####"

puts #Alsovalid# ;# comment here!
puts {;#and this}
puts {really anything -$#;/ /\ \ -_'@?` "\".$?"!'][¨@ is allowed in curly braces}

puts "3 == [foo 1 2] and 6 == [foo 2]"

set function "#weird"
set code [catch {[$function]}]
puts "$code == 5"