mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-27 06:48:31 +00:00
Improve Python and Linenoise
This change reinvents all the GNU Readline features I discovered that I couldn't live without, e.g. UTF-8, CTRL-R search and CTRL-Y yanking. It now feels just as good in terms of user interface from the subconscious workflow perspective. It's real nice to finally have an embeddable line reader that's actually good with a 30 kb footprint and a bsd-2 license. This change adds a directory to the examples folder, explaining how the new Python compiler may be used. Some of the bugs with Python binaries have been addressed but overall it's still a work in progress.
This commit is contained in:
parent
ad52387b74
commit
51904e2687
35 changed files with 3541 additions and 8587 deletions
28
test/libc/str/strclen_test.c
Normal file
28
test/libc/str/strclen_test.c
Normal file
|
@ -0,0 +1,28 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2021 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/testlib/testlib.h"
|
||||
|
||||
TEST(strclen, test) {
|
||||
EXPECT_EQ(0, strclen(""));
|
||||
EXPECT_EQ(5, strclen("hello"));
|
||||
EXPECT_EQ(7, strclen("☺☻♥♦♣♠•"));
|
||||
EXPECT_EQ(9, strclen("e☺e☻♥♦♣♠•"));
|
||||
}
|
|
@ -21,29 +21,35 @@
|
|||
#include "libc/testlib/ezbench.h"
|
||||
#include "libc/testlib/testlib.h"
|
||||
|
||||
TEST(iswupper, test) {
|
||||
EXPECT_TRUE(iswupper(L'𝐵'));
|
||||
}
|
||||
|
||||
TEST(towupper, test) {
|
||||
EXPECT_EQ(u'!', towupper(u'!'));
|
||||
EXPECT_EQ(u'A', towupper(u'a'));
|
||||
EXPECT_EQ(u'À', towupper(u'à'));
|
||||
if (IsTiny()) return;
|
||||
EXPECT_EQ(L'𝛥', towupper(L'𝛿'));
|
||||
EXPECT_EQ(L'B', towupper(L'b'));
|
||||
EXPECT_EQ(u'Ꭰ', towupper(u'ꭰ'));
|
||||
}
|
||||
|
||||
TEST(towlower, test) {
|
||||
EXPECT_EQ(u'!', towlower(u'!'));
|
||||
EXPECT_EQ(u'a', towlower(u'A'));
|
||||
EXPECT_EQ(u'à', towlower(u'À'));
|
||||
if (IsTiny()) return;
|
||||
EXPECT_EQ(L'𝛿', towlower(L'𝛥'));
|
||||
EXPECT_EQ(L'b', towlower(L'B'));
|
||||
EXPECT_EQ(u'ꭰ', towlower(u'Ꭰ'));
|
||||
}
|
||||
|
||||
BENCH(towupper, bench) {
|
||||
EZBENCH2("towupper ascii", donothing, EXPROPRIATE(towupper(VEIL("r", L'a'))));
|
||||
EZBENCH2("towupper latin1", donothing,
|
||||
EXPROPRIATE(towupper(VEIL("r", u'A'))));
|
||||
if (IsTiny()) return;
|
||||
EZBENCH2("towupper watinc", donothing,
|
||||
EXPROPRIATE(towupper(VEIL("r", u'Ỿ'))));
|
||||
EZBENCH2("towupper greek", donothing, EXPROPRIATE(towupper(VEIL("r", u'α'))));
|
||||
EZBENCH2("towupper astral", donothing,
|
||||
EXPROPRIATE(towupper(VEIL("r", L'𝛿'))));
|
||||
}
|
||||
|
@ -52,7 +58,9 @@ BENCH(towlower, bench) {
|
|||
EZBENCH2("towlower ascii", donothing, EXPROPRIATE(towlower(VEIL("r", L'a'))));
|
||||
EZBENCH2("towlower latin1", donothing,
|
||||
EXPROPRIATE(towlower(VEIL("r", u'A'))));
|
||||
if (IsTiny()) return;
|
||||
EZBENCH2("towlower watinc", donothing,
|
||||
EXPROPRIATE(towlower(VEIL("r", u'Ỿ'))));
|
||||
EZBENCH2("towlower greek", donothing, EXPROPRIATE(towupper(VEIL("r", u'α'))));
|
||||
EZBENCH2("towlower astral", donothing,
|
||||
EXPROPRIATE(towlower(VEIL("r", L'𝛿'))));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue