

def test_example_5_14(self):
    example_5_14 = '\n        ; Example 5-14.  Simple 16-bit square root.\n        ;\n        ; Returns the 8-bit square root in $20 of the\n        ; 16-bit number in $20 (low) and $21 (high). The\n        ; remainder is in location $21.\n\n        sqrt16: LDY #$01     ; lsby of first odd number = 1\n                STY $22\n                DEY\n                STY $23      ; msby of first odd number (sqrt = 0)\n        again:  SEC\n                LDA $20      ; save remainder in X register\n                TAX          ; subtract odd lo from integer lo\n                SBC $22\n                STA $20\n                LDA $21      ; subtract odd hi from integer hi\n                SBC $23\n                STA $21      ; is subtract result negative?\n                BCC nomore   ; no. increment square root\n                INY\n                LDA $22      ; calculate next odd number\n                ADC #$01\n                STA $22\n                BCC again\n                INC $23\n                JMP again\n        nomore: STY $20      ; all done, store square root\n                STX $21      ; and remainder\n                RTS\n        '
    tokens = list(lexical(example_5_14))
    self.assertEquals(74, len(tokens))
    self.assertEquals('T_ENDLINE', tokens[0]['type'])
    self.assertEquals('T_ENDLINE', tokens[1]['type'])
    self.assertEquals('T_ENDLINE', tokens[2]['type'])
    self.assertEquals('T_ENDLINE', tokens[3]['type'])
    self.assertEquals('T_ENDLINE', tokens[4]['type'])
    self.assertEquals('T_ENDLINE', tokens[5]['type'])
    self.assertEquals('T_ENDLINE', tokens[6]['type'])
    self.assertEquals('T_LABEL', tokens[7]['type'])
    self.assertEquals('T_INSTRUCTION', tokens[8]['type'])
    self.assertEquals('T_HEX_NUMBER', tokens[9]['type'])
    self.assertEquals('T_ENDLINE', self[10]['type'])
    self.assertEquals('T_INSTRUCTION', tokens[11]['type'])
    self.assertEquals('T_ADDRESS', tokens[12]['type'])
    self.assertEquals('T_ENDLINE', tokens[13]['type'])
    self.assertEquals('T_INSTRUCTION', tokens[14]['type'])
    self.assertEquals('T_ENDLINE', tokens[15]['type'])
    self.assertEquals('T_INSTRUCTION', tokens[16]['type'])
    self.assertEquals('T_ADDRESS', tokens[17]['type'])
    self.assertEquals('T_ENDLINE', tokens[18]['type'])

dataset/ETHPy150Open gutomaia/pyNES/pynes/tests/guide_test.py GuideTest.test_example_5_14/VarMisuse@192/724 `tokens`->`self`