mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 03:20:18 +00:00
...
This commit is contained in:
parent
e25cc48463
commit
61e36941a9
@ -447,7 +447,10 @@ static Error* lex_one_token(Lexer* self, bool* eof, bool is_fstring) {
|
|||||||
}
|
}
|
||||||
case ',': add_token(self, TK_COMMA); return NULL;
|
case ',': add_token(self, TK_COMMA); return NULL;
|
||||||
case ':': {
|
case ':': {
|
||||||
if(is_fstring) { return eat_fstring_spec(self, eof); }
|
if(is_fstring) {
|
||||||
|
// BUG: f"{stack[2:]}"
|
||||||
|
return eat_fstring_spec(self, eof);
|
||||||
|
}
|
||||||
add_token(self, TK_COLON);
|
add_token(self, TK_COLON);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -199,8 +199,6 @@ assert chr(0x1f955) == '🥕'
|
|||||||
assert ord('测') == 27979
|
assert ord('测') == 27979
|
||||||
assert chr(27979) == '测'
|
assert chr(27979) == '测'
|
||||||
|
|
||||||
exit()
|
|
||||||
|
|
||||||
# test format()
|
# test format()
|
||||||
assert "Hello, {}!".format("World") == "Hello, World!"
|
assert "Hello, {}!".format("World") == "Hello, World!"
|
||||||
assert "{} {} {}".format("I", "love", "Python") == "I love Python"
|
assert "{} {} {}".format("I", "love", "Python") == "I love Python"
|
||||||
@ -214,14 +212,19 @@ assert "{0}={1}".format('{0}', '{1}') == "{0}={1}"
|
|||||||
assert "{{{0}}}".format(1) == "{1}"
|
assert "{{{0}}}".format(1) == "{1}"
|
||||||
assert "{0}{1}{1}".format(1, 2, 3) == "122"
|
assert "{0}{1}{1}".format(1, 2, 3) == "122"
|
||||||
|
|
||||||
# try:
|
try:
|
||||||
# "{0}={1}}".format(1, 2)
|
"{0}={1}}".format(1, 2)
|
||||||
# exit(1)
|
exit(1)
|
||||||
# except ValueError:
|
except ValueError:
|
||||||
# pass
|
pass
|
||||||
|
|
||||||
assert "{{{}xxx{}x}}".format(1, 2) == "{1xxx2x}"
|
assert "{{{}xxx{}x}}".format(1, 2) == "{1xxx2x}"
|
||||||
assert "{{abc}}".format() == "{abc}"
|
assert "{{abc}}".format() == "{abc}"
|
||||||
|
|
||||||
# test f-string
|
# test f-string
|
||||||
# stack=[1,2,3,4]; assert f"{stack[2:]}" == '[3, 4]'
|
assert f"{1+2}" == "3"
|
||||||
|
# assert f"{1, 2, 3}" == "(1, 2, 3)"
|
||||||
|
assert f"{(1, 2, 3)}" == "(1, 2, 3)"
|
||||||
|
|
||||||
|
# stack=[1,2,3,4]
|
||||||
|
# assert f"{stack[2:]}" == '[3, 4]'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user