コード例 #1
0
 def test_visitSetPenSizeTo(self):
     context = create_block_context("pen_setPenSizeTo")
     testblock = context.block
     addInputOfType(testblock, "SIZE", LiteralType.INT)
     converted_block = visitBlock(context)
     assert converted_block[0] == "penSize:"
     assert converted_block[1] == 1234
コード例 #2
0
 def test_visitStop(self):
     context = create_block_context("control_stop")
     testblock = context.block
     testblock.fields["STOP_OPTION"] = ["stopthisscript"]
     converted_block = visitBlock(context)
     assert converted_block[0] == "stopScripts"
     assert converted_block[1] == "stopthisscript"
コード例 #3
0
 def test_visitSetPenColorToColor(self):
     context = create_block_context("pen_setPenColorToColor")
     testblock = context.block
     addInputOfType(testblock, "COLOR", LiteralType.STRING)
     converted_block = visitBlock(context)
     assert converted_block[0] == "penColor:"
     assert converted_block[1] == "teststring"
コード例 #4
0
 def test_visitLengthoflist(self):
     context = create_block_context("data_lengthoflist")
     testblock = context.block
     testblock.fields["LIST"] = ["testlist"]
     converted_block = visitBlock(context)
     assert converted_block[0] == "lineCountOfList:"
     assert converted_block[1] == "testlist"
コード例 #5
0
 def test_visitContentsoflist(self):
     context = create_block_context("data_contentsoflist")
     testblock = context.block
     testblock.fields["LIST"] = ["testlist"]
     converted_block = visitBlock(context)
     assert converted_block[0] == "contentsOfList:"
     assert converted_block[1] == "testlist"
コード例 #6
0
    def test_visitUsername(self):
        context = create_block_context("sensing_username")
        testblock = context.block

        converted_block = visitBlock(context)

        assert converted_block[0] == "getUserName"
コード例 #7
0
 def test_visitHidevariable(self):
     context = create_block_context("data_hidevariable")
     testblock = context.block
     testblock.fields["VARIABLE"] = ["testvar"]
     converted_block = visitBlock(context)
     assert converted_block[0] == "hideVariable:"
     assert converted_block[1] == "testvar"
コード例 #8
0
    def test_visitMousey(self):
        context = create_block_context("sensing_mousey")
        testblock = context.block

        converted_block = visitBlock(context)

        assert converted_block[0] == "mouseY"
コード例 #9
0
    def test_visitTimer(self):
        context = create_block_context("sensing_timer")
        testblock = context.block

        converted_block = visitBlock(context)

        assert converted_block[0] == "timer"
コード例 #10
0
    def test_visitDayssince2000(self):
        context = create_block_context("sensing_dayssince2000")
        testblock = context.block

        converted_block = visitBlock(context)

        assert converted_block[0] == "timestamp"
コード例 #11
0
 def test_visitSetvolumeto(self):
     context = create_block_context("sound_setvolumeto")
     testblock = context.block
     addInputOfType(testblock, "VOLUME", LiteralType.INT)
     converted_block = visitBlock(context)
     assert converted_block[0] == "setVolumeTo:"
     assert converted_block[1] == 1234.0
コード例 #12
0
 def test_visitGoforwardbackwardlayers(self):
     context = create_block_context("looks_goforwardbackwardlayers")
     testblock = context.block
     testblock.fields["FORWARD_BACKWARD"] = ["forward"]
     addInputOfType(testblock, "NUM", LiteralType.INT)
     converted_block = visitBlock(context)
     assert converted_block[0] == "goBackByLayers:"
コード例 #13
0
 def test_visitChangePenSizeBy(self):
     context = create_block_context("pen_changePenSizeBy")
     testblock = context.block
     addInputOfType(testblock, "SIZE", LiteralType.INT)
     converted_block = visitBlock(context)
     assert converted_block[0] == "changePenSizeBy:"
     assert converted_block[1] == 1234
コード例 #14
0
    def test_visitDayssince2000(self):
        context = create_block_context("sensing_dayssince2000")
        testblock = context.block

        converted_block = visitBlock(context)

        assert converted_block[0] == "timestamp"
コード例 #15
0
    def test_visitDirection(self):
        context = create_block_context("motion_direction")
        testblock = context.block

        converted_block = visitBlock(context)

        assert converted_block[0] == "heading"
コード例 #16
0
 def test_visitLengthoflist(self):
     context = create_block_context("data_lengthoflist")
     testblock = context.block
     testblock.fields["LIST"] = ["testlist"]
     converted_block = visitBlock(context)
     assert converted_block[0] == "lineCountOfList:"
     assert converted_block[1] == "testlist"
コード例 #17
0
    def test_visitDirection(self):
        context = create_block_context("motion_direction")
        testblock = context.block

        converted_block = visitBlock(context)

        assert converted_block[0] == "heading"
コード例 #18
0
 def test_visitChangevolumeby(self):
     context = create_block_context("sound_changevolumeby")
     testblock = context.block
     addInputOfType(testblock, "VOLUME", TYPE_INT)
     converted_block = visitBlock(context)
     assert converted_block[0] == "changeVolumeBy:"
     assert converted_block[1] == 1234.0
コード例 #19
0
 def test_visitSetvolumeto(self):
     context = create_block_context("sound_setvolumeto")
     testblock = context.block
     addInputOfType(testblock, "VOLUME", TYPE_INT)
     converted_block = visitBlock(context)
     assert converted_block[0] == "setVolumeTo:"
     assert converted_block[1] == 1234.0
コード例 #20
0
 def test_visitPlayuntildone(self):
     context = create_block_context("sound_playuntildone")
     testblock = context.block
     self.add_menu_block(context, "sound_sounds_menu", "SOUND_MENU", "test_sound")
     converted_block = visitBlock(context)
     assert converted_block[0] == "doPlaySoundAndWait"
     assert converted_block[1] == "test_sound"
コード例 #21
0
    def test_visitYposition(self):
        context = create_block_context("motion_yposition")
        testblock = context.block

        converted_block = visitBlock(context)

        assert converted_block[0] == "ypos"
コード例 #22
0
 def test_visitGoforwardbackwardlayers(self):
     context = create_block_context("looks_goforwardbackwardlayers")
     testblock = context.block
     testblock.fields["FORWARD_BACKWARD"] = ["forward"]
     addInputOfType(testblock, "NUM", TYPE_INT)
     converted_block = visitBlock(context)
     assert converted_block[0] == "goBackByLayers:"
コード例 #23
0
    def test_visitUsername(self):
        context = create_block_context("sensing_username")
        testblock = context.block

        converted_block = visitBlock(context)

        assert converted_block[0] == "getUserName"
コード例 #24
0
    def test_visitTimer(self):
        context = create_block_context("sensing_timer")
        testblock = context.block

        converted_block = visitBlock(context)

        assert converted_block[0] == "timer"
コード例 #25
0
 def test_visitHidevariable(self):
     context = create_block_context("data_hidevariable")
     testblock = context.block
     testblock.fields["VARIABLE"] = ["testvar"]
     converted_block = visitBlock(context)
     assert converted_block[0] == "hideVariable:"
     assert converted_block[1] == "testvar"
コード例 #26
0
    def test_visitMousey(self):
        context = create_block_context("sensing_mousey")
        testblock = context.block

        converted_block = visitBlock(context)

        assert converted_block[0] == "mouseY"
コード例 #27
0
 def test_visitStop(self):
     context = create_block_context("control_stop")
     testblock = context.block
     testblock.fields["STOP_OPTION"] = ["stopthisscript"]
     converted_block = visitBlock(context)
     assert converted_block[0] == "stopScripts"
     assert converted_block[1] == "stopthisscript"
コード例 #28
0
 def test_visitContentsoflist(self):
     context = create_block_context("data_contentsoflist")
     testblock = context.block
     testblock.fields["LIST"] = ["testlist"]
     converted_block = visitBlock(context)
     assert converted_block[0] == "contentsOfList:"
     assert converted_block[1] == "testlist"
コード例 #29
0
    def test_visitYposition(self):
        context = create_block_context("motion_yposition")
        testblock = context.block

        converted_block = visitBlock(context)

        assert converted_block[0] == "ypos"
コード例 #30
0
    def test_showSpriteBlock(self):
        context = create_block_context("show")
        testblock = context.block
        addInputToBlock(testblock,"myval", 1)
        converted_block = visitBlock(context)

        assert converted_block
コード例 #31
0
    def test_visitSetdragmode(self):
        context = create_block_context("sensing_setdragmode")
        testblock = context.block
        testblock.fields["DRAG_MODE"] = ["mode"]

        converted_block = visitBlock(context)
        assert converted_block[0] == "dragMode"
        assert converted_block[1] == "mode"
コード例 #32
0
    def test_visitChangeyby(self):
        context = create_block_context("motion_changeyby")
        testblock = context.block
        addInputOfType(testblock, "DY", TYPE_INT)
        converted_block = visitBlock(context)

        assert converted_block[0] == "changeYposBy:"
        assert converted_block[1] == 1234
コード例 #33
0
    def test_visitPointtowards(self):
        context = create_block_context("motion_pointtowards")
        testblock = context.block
        addInputOfType(testblock, "TOWARDS", TYPE_INT)
        converted_block = visitBlock(context)

        assert converted_block[0] == "pointTowards:"
        assert converted_block[1] == 1234
コード例 #34
0
    def test_visitPointindirection(self):
        context = create_block_context("motion_pointindirection")
        testblock = context.block
        addInputOfType(testblock, "DIRECTION", TYPE_INT)
        converted_block = visitBlock(context)

        assert converted_block[0] == "heading:"
        assert converted_block[1] == 1234
コード例 #35
0
    def test_visitGoto(self):
        context = create_block_context("motion_goto")
        testblock = context.block
        addInputOfType(testblock, "TO", TYPE_STRING)
        converted_block = visitBlock(context)

        assert converted_block[0] == "gotoSpriteOrMouse:"
        assert converted_block[1] == "teststring"
コード例 #36
0
    def test_visitTurnleft(self):
        context = create_block_context("motion_turnleft")
        testblock = context.block
        addInputOfType(testblock, "DEGREES", TYPE_INT)
        converted_block = visitBlock(context)

        assert converted_block[0] == "turnLeft:"
        assert converted_block[1] == 1234
コード例 #37
0
    def test_visitMovesteps(self):
        context = create_block_context("motion_movesteps")
        testblock = context.block
        addInputOfType(testblock, "STEPS", TYPE_INT)
        converted_block = visitBlock(context)

        assert converted_block[0] == "forward:"
        assert converted_block[1] == 1234
コード例 #38
0
    def test_visitThink(self):
        context = create_block_context("looks_think")
        testblock = context.block
        addInputOfType(testblock, "MESSAGE", TYPE_STRING)

        converted_block = visitBlock(context)
        assert converted_block[0] == "think:"
        assert converted_block[1] == "teststring"
コード例 #39
0
    def test_visitSetsizeto(self):
        context = create_block_context("looks_setsizeto")
        testblock = context.block
        addInputOfType(testblock, "SIZE", TYPE_INT)

        converted_block = visitBlock(context)
        assert converted_block[0] == "setSizeTo:"
        assert converted_block[1] == 1234.0
コード例 #40
0
    def test_visitSety(self):
        context = create_block_context("motion_sety")
        testblock = context.block
        addInputOfType(testblock, "Y", TYPE_INT)
        converted_block = visitBlock(context)

        assert converted_block[0] == "ypos:"
        assert converted_block[1] == 1234
コード例 #41
0
 def test_visitWait(self):
     context = create_block_context("control_wait")
     testblock = context.block
     addInputOfType(testblock, "DURATION", TYPE_INT)
     addInputOfType(testblock, "SUBSTACK", TYPE_BLOCK)
     converted_block = visitBlock(context)
     assert converted_block[0] == "wait:elapsed:from:"
     assert converted_block[1] == 1234
コード例 #42
0
    def test_visitChangesizeby(self):
        context = create_block_context("looks_changesizeby")
        testblock = context.block
        addInputOfType(testblock, "CHANGE", TYPE_INT)

        converted_block = visitBlock(context)
        assert converted_block[0] == "changeSizeBy:"
        assert converted_block[1] == 1234.0
コード例 #43
0
    def test_visitTurnright(self):
        context = create_block_context("motion_turnright")
        testblock = context.block
        addInputOfType(testblock, "DEGREES", LiteralType.INT)
        converted_block = visitBlock(context)

        assert converted_block[0] == "turnRight:"
        assert converted_block[1] == 1234
コード例 #44
0
 def test_visitGt(self):
     context = create_block_context("operator_gt")
     testblock = context.block
     addInputOfType(testblock, "OPERAND1", TYPE_INT)
     addInputOfType(testblock, "OPERAND2", TYPE_INT)
     converted_block = visitBlock(context)
     assert converted_block[0] == ">"
     assert converted_block[1] == 1234
     assert converted_block[2] == 1234
コード例 #45
0
 def test_visitJoin(self):
     context = create_block_context("operator_join")
     testblock = context.block
     addInputOfType(testblock, "STRING1", TYPE_STRING)
     addInputOfType(testblock, "STRING2", TYPE_STRING)
     converted_block = visitBlock(context)
     assert converted_block[0] == "concatenate:with:"
     assert converted_block[1] == "teststring"
     assert converted_block[2] == "teststring"
コード例 #46
0
 def test_visitSubtract(self):
     context = create_block_context("operator_subtract")
     testblock = context.block
     addInputOfType(testblock, "NUM1", TYPE_INT)
     addInputOfType(testblock, "NUM2", TYPE_INT)
     converted_block = visitBlock(context)
     assert converted_block[0] == "-"
     assert converted_block[1] == 1234
     assert converted_block[2] == 1234