-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Zig: Fixed module comments and astral chars
- Loading branch information
1 parent
3d96eed
commit 0702804
Showing
4 changed files
with
184 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// normal comment | ||
|
||
/// A structure for storing a timestamp, with nanosecond precision (this is a | ||
/// multiline doc comment). | ||
|
||
//! This module provides functions for retrieving the current date and | ||
//! time with varying degrees of precision and accuracy. It does not | ||
//! depend on libc, but will use functions from it if available. | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["comment", "// normal comment"], | ||
|
||
["comment", "/// A structure for storing a timestamp, with nanosecond precision (this is a"], | ||
["comment", "/// multiline doc comment)."], | ||
|
||
["comment", "//! This module provides functions for retrieving the current date and"], | ||
["comment", "//! time with varying degrees of precision and accuracy. It does not"], | ||
["comment", "//! depend on libc, but will use functions from it if available."] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
// source: https://ziglang.org/documentation/master/#String-Literals-and-Character-Literals | ||
|
||
const expect = @import("std").testing.expect; | ||
const mem = @import("std").mem; | ||
|
||
test "string literals" { | ||
const bytes = "hello"; | ||
expect(@TypeOf(bytes) == *const [5:0]u8); | ||
expect(bytes.len == 5); | ||
expect(bytes[1] == 'e'); | ||
expect(bytes[5] == 0); | ||
expect('e' == '\x65'); | ||
expect('\u{1f4a9}' == 128169); | ||
expect('💯' == 128175); | ||
expect(mem.eql(u8, "hello", "h\x65llo")); | ||
} | ||
|
||
const hello_world_in_c = | ||
\\#include <stdio.h> | ||
\\ | ||
\\int main(int argc, char **argv) { | ||
\\ printf("hello world\n"); | ||
\\ return 0; | ||
\\} | ||
; | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["comment", "// source: https://ziglang.org/documentation/master/#String-Literals-and-Character-Literals"], | ||
|
||
["keyword", "const"], | ||
" expect ", | ||
["operator", "="], | ||
["builtin", "@import"], | ||
["punctuation", "("], | ||
["string", "\"std\""], | ||
["punctuation", ")"], | ||
["punctuation", "."], | ||
"testing", | ||
["punctuation", "."], | ||
"expect", | ||
["punctuation", ";"], | ||
|
||
["keyword", "const"], | ||
" mem ", | ||
["operator", "="], | ||
["builtin", "@import"], | ||
["punctuation", "("], | ||
["string", "\"std\""], | ||
["punctuation", ")"], | ||
["punctuation", "."], | ||
"mem", | ||
["punctuation", ";"], | ||
|
||
["keyword", "test"], | ||
["string", "\"string literals\""], | ||
["punctuation", "{"], | ||
|
||
["keyword", "const"], | ||
" bytes ", | ||
["operator", "="], | ||
["string", "\"hello\""], | ||
["punctuation", ";"], | ||
|
||
["function", "expect"], | ||
["punctuation", "("], | ||
["builtin", "@TypeOf"], | ||
["punctuation", "("], | ||
"bytes", | ||
["punctuation", ")"], | ||
["operator", "=="], | ||
["operator", "*"], | ||
["keyword", "const"], | ||
["punctuation", "["], | ||
["number", "5"], | ||
["punctuation", ":"], | ||
["number", "0"], | ||
["punctuation", "]"], | ||
["builtin-types", "u8"], | ||
["punctuation", ")"], | ||
["punctuation", ";"], | ||
|
||
["function", "expect"], | ||
["punctuation", "("], | ||
"bytes", | ||
["punctuation", "."], | ||
"len ", | ||
["operator", "=="], | ||
["number", "5"], | ||
["punctuation", ")"], | ||
["punctuation", ";"], | ||
|
||
["function", "expect"], | ||
["punctuation", "("], | ||
"bytes", | ||
["punctuation", "["], | ||
["number", "1"], | ||
["punctuation", "]"], | ||
["operator", "=="], | ||
["string", "'e'"], | ||
["punctuation", ")"], | ||
["punctuation", ";"], | ||
|
||
["function", "expect"], | ||
["punctuation", "("], | ||
"bytes", | ||
["punctuation", "["], | ||
["number", "5"], | ||
["punctuation", "]"], | ||
["operator", "=="], | ||
["number", "0"], | ||
["punctuation", ")"], | ||
["punctuation", ";"], | ||
|
||
["function", "expect"], | ||
["punctuation", "("], | ||
["string", "'e'"], | ||
["operator", "=="], | ||
["string", "'\\x65'"], | ||
["punctuation", ")"], | ||
["punctuation", ";"], | ||
|
||
["function", "expect"], | ||
["punctuation", "("], | ||
["string", "'\\u{1f4a9}'"], | ||
["operator", "=="], | ||
["number", "128169"], | ||
["punctuation", ")"], | ||
["punctuation", ";"], | ||
|
||
["function", "expect"], | ||
["punctuation", "("], | ||
["string", "'💯'"], | ||
["operator", "=="], | ||
["number", "128175"], | ||
["punctuation", ")"], | ||
["punctuation", ";"], | ||
|
||
["function", "expect"], | ||
["punctuation", "("], | ||
"mem", | ||
["punctuation", "."], | ||
["function", "eql"], | ||
["punctuation", "("], | ||
["builtin-types", "u8"], | ||
["punctuation", ","], | ||
["string", "\"hello\""], | ||
["punctuation", ","], | ||
["string", "\"h\\x65llo\""], | ||
["punctuation", ")"], | ||
["punctuation", ")"], | ||
["punctuation", ";"], | ||
|
||
["punctuation", "}"], | ||
|
||
["keyword", "const"], " hello_world_in_c ", ["operator", "="], | ||
["string", " \\\\#include <stdio.h>\r\n \\\\\r\n \\\\int main(int argc, char **argv) {\r\n \\\\ printf(\"hello world\\n\");\r\n \\\\ return 0;\r\n \\\\}"], | ||
["punctuation", ";"] | ||
] |