mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-19 19:10:17 +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 ':': {
|
||||
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);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -199,8 +199,6 @@ assert chr(0x1f955) == '🥕'
|
||||
assert ord('测') == 27979
|
||||
assert chr(27979) == '测'
|
||||
|
||||
exit()
|
||||
|
||||
# test format()
|
||||
assert "Hello, {}!".format("World") == "Hello, World!"
|
||||
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}{1}{1}".format(1, 2, 3) == "122"
|
||||
|
||||
# try:
|
||||
# "{0}={1}}".format(1, 2)
|
||||
# exit(1)
|
||||
# except ValueError:
|
||||
# pass
|
||||
try:
|
||||
"{0}={1}}".format(1, 2)
|
||||
exit(1)
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
assert "{{{}xxx{}x}}".format(1, 2) == "{1xxx2x}"
|
||||
assert "{{abc}}".format() == "{abc}"
|
||||
|
||||
# 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