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

Nested calls not working, result not interpreted #54

Open
jbruchanov opened this issue Nov 9, 2017 · 0 comments
Open

Nested calls not working, result not interpreted #54

jbruchanov opened this issue Nov 9, 2017 · 0 comments

Comments

@jbruchanov
Copy link

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"))//failing

javascript 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'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant