-
Notifications
You must be signed in to change notification settings - Fork 38
Open
Description
val script = """
+ simple1
- <call>test "<bot VAR1>"</call>
+ complex
- {@ something <call>test "<bot VAR1>"</call>}
+ interpret
- {@ build <call>test interpret</call>}
+ setvar *
- <bot VAR1=<star>>Var updated
+ getvar
- Var1 is '<bot VAR1>'
+ something *
- SomethingRef=<star>
+ build *
- <bot VAR1=<star>>
> object test javascript
return "Test:" + args[0]
< object
> object interpret javascript
return "<bot VAR1=interpret>"
< object
""".trimIndent()
val user = "user"
val re = RiveScript(Config.newBuilder()
.strict(true)
.utf8(true)
.build()).apply {
stream(script)
sortReplies()
setSubroutine("test", { re, args -> "Test:" + args[0] })
setSubroutine("interpret", { re, args -> "<bot VAR1=interpret>" })
}
assertEquals("Var updated", re.reply(user, "setvar 123"))
assertEquals("Var1 is '123'", re.reply(user, "getvar"))
assertEquals("Test:123", re.reply(user, "simple1"))
assertEquals("SomethingRef=Test:123", re.reply(user, "complex"))//failing, is '{__call__test "123"</call>}'
assertEquals("", re.reply(user, "interpret"))//failing, is 'test interpret</call>}'
assertEquals("Var1 is 'Test:interpret'", re.reply(user, "getvar"))//failingjavascript result (from https://www.rivescript.com/try)
User: setvar 123
Bot: Var updated
User: getvar
Bot: Var1 is '123'
User: simple1
Bot: Test:123
User: complex
Bot: SomethingRef=Test:123
User: interpret
Bot:
User: getvar
Bot: Var1 is 'Test:interpret'
Metadata
Metadata
Assignees
Labels
No labels