Esempio n. 1
0
    def test_assign_bengali(self):
        hashed_var = hedy.hash_var("নাম")

        code = textwrap.dedent("""\
    নাম is হেডি""")

        expected = textwrap.dedent(f"""\
    {hashed_var} = 'হেডি'""")

        self.single_level_tester(code=code, expected=expected)
Esempio n. 2
0
    def test_assign_print_chinese(self):
        hashed_var = hedy.hash_var("你好世界")
        self.assertEqual('v65396ee4aad0b4f17aacd1c6112ee364', hashed_var)

        code = textwrap.dedent("""\
    你好世界 is 你好世界
    print 你好世界""")
        expected = textwrap.dedent("""\
    v65396ee4aad0b4f17aacd1c6112ee364 = '你好世界'
    print(f'{v65396ee4aad0b4f17aacd1c6112ee364}')""")

        self.single_level_tester(code=code, expected=expected)
Esempio n. 3
0
    def test_assign_print_bengali(self):
        hashed_var = hedy.hash_var("নাম")
        self.assertEqual('veb9b5c786e8cde0910df4197f630ee75', hashed_var)

        code = textwrap.dedent("""\
    নাম is হেডি
    print 'আমার নাম is ' নাম """)
        expected = textwrap.dedent("""\
    veb9b5c786e8cde0910df4197f630ee75 = 'হেডি'
    print(f'আমার নাম is {veb9b5c786e8cde0910df4197f630ee75}')""")

        self.single_level_tester(code=code, expected=expected)
Esempio n. 4
0
    def test_assign_Python_keyword(self):
        hashed_var = hedy.hash_var("for")

        code = textwrap.dedent("""\
    for is Hedy
    print 'ik heet ' for """)

        expected = textwrap.dedent("""\
    vd55669822f1a8cf72ec1911e462a54eb = 'Hedy'
    print(f'ik heet {vd55669822f1a8cf72ec1911e462a54eb}')""")

        self.single_level_tester(code=code, expected=expected)
Esempio n. 5
0
    def test_bengali_assign(self):
        hashed_var = hedy.hash_var("নাম")

        code = textwrap.dedent("""\
    নাম is হেডি""")

        result = hedy.transpile(code, self.level)

        expected = textwrap.dedent(f"""\
    {hashed_var} = 'হেডি'""")

        self.assertEqual(expected, result.code)
        self.assertEqual(False, result.has_turtle)
Esempio n. 6
0
    def test_chinese_assign_and_use(self):
        hashed_var = hedy.hash_var("你好世界")

        code = textwrap.dedent("""\
    你好世界 is 你好世界
    print 你好世界""")

        result = hedy.transpile(code, self.level)

        expected = textwrap.dedent(f"""\
    {hashed_var} = '你好世界'
    print({hashed_var})""")

        self.assertEqual(expected, result.code)
Esempio n. 7
0
    def test_bengali_assign_and_use(self):
        hashed_var = hedy.hash_var("নাম")

        code = textwrap.dedent("""\
    নাম is হেডি
    print 'আমার নাম is ' নাম """)

        result = hedy.transpile(code, self.level)

        expected = textwrap.dedent(f"""\
    {hashed_var} = 'হেডি'
    print('আমার নাম is '+{hashed_var})""")

        self.assertEqual(expected, result.code)
Esempio n. 8
0
    def test_name_that_is_keyword(self):
        hashed_var = hedy.hash_var("for")

        code = textwrap.dedent("""\
    for is Hedy
    print 'ik heet ' for """)

        result = hedy.transpile(code, self.level)

        expected = textwrap.dedent(f"""\
    {hashed_var} = 'Hedy'
    print('ik heet '+{hashed_var})""")

        self.assertEqual(expected, result.code)
        self.assertEqual(False, result.has_turtle)
Esempio n. 9
0
    def test_chinese_assign_and_use(self):
        hashed_var = hedy.hash_var("你好世界")
        self.assertEqual('v65396ee4aad0b4f17aacd1c6112ee364', hashed_var)

        code = textwrap.dedent("""\
    你好世界 is 你好世界
    print 你好世界""")

        result = hedy.transpile(code, self.level)

        expected = textwrap.dedent("""\
    v65396ee4aad0b4f17aacd1c6112ee364 = '你好世界'
    print(f'{v65396ee4aad0b4f17aacd1c6112ee364}')""")

        self.assertEqual(expected, result.code)
Esempio n. 10
0
    def test_bengali_assign_and_use(self):
        hashed_var = hedy.hash_var("নাম")
        self.assertEqual('veb9b5c786e8cde0910df4197f630ee75', hashed_var)

        code = textwrap.dedent("""\
    নাম is হেডি
    print 'আমার নাম is ' নাম """)

        result = hedy.transpile(code, self.level)

        expected = textwrap.dedent("""\
    veb9b5c786e8cde0910df4197f630ee75 = 'হেডি'
    print(f'আমার নাম is {veb9b5c786e8cde0910df4197f630ee75}')""")

        self.assertEqual(expected, result.code)
Esempio n. 11
0
    def test_name_that_is_keyword(self):
        hashed_var = hedy.hash_var("for")

        code = textwrap.dedent("""\
    for is Hedy
    print 'ik heet ' for """)

        result = hedy.transpile(code, self.level)

        expected = textwrap.dedent("""\
    vd55669822f1a8cf72ec1911e462a54eb = 'Hedy'
    print(f'ik heet {vd55669822f1a8cf72ec1911e462a54eb}')""")

        self.assertEqual(expected, result.code)
        self.assertEqual(False, result.has_turtle)