蓝色天空.知识 · 实践 · 创造
我的收藏
在线代码实验室

Zig 注释:行注释、文档注释与非法块注释:本章真实编译测试

ZIGWindows / Zig0.14.1 / Debug模式;0.15+及其它系统另验zig-comments.zig
zig-comments.zig16 行
//! Container-level learning notes, independently authored.
const std = @import("std");
const expect = std.testing.expect;
const eq = std.testing.expectEqual;
/// Adds two fixed-width integers.
fn add(a: i32, b: i32) i32 {
    // This line is a comment, not a second assignment.
    // return 999;
    return a + b; // End-of-line explanation.
}
test "line and documentation comments preserve behavior" {
    try eq(@as(i32, 30), add(10, 20));
    // Several lines of explanation use several // prefixes.
    // C-style block syntax is a separately rejected negative case.
}
本例需在 Windows / Zig0.14.1 / Debug模式;0.15+及其它系统另验 中运行,请复制源码、保存文件或下载工程包后在本地执行验证。
运行说明与环境独立工程

运行环境:Windows / Zig0.14.1 / Debug模式;0.15+及其它系统另验

入口文件:projects/zig-lab/zig-comments.zig

预期结果与验证条件观察提示
  • 该文件全部具名测试真实通过,未跳过或把编译成功当成执行完成。
  • 具体输入、分支及数值由本章源码的expect/eq/expectError逐项核对;源码哈希与运行记录对应。

请结合实际环境逐项观察。

附件与关联工程包下载

下载课程关联工程包:Zig

课程关联工程包(登记关联14章) · 含当前章节或实例 · mbskycom202611a544.zip
SITE SEARCH

搜索教程、工具与资讯

热门搜索

JavaScriptJSON格式化正则表达式AI 编程AI 翻译AI导航专题标签
Esc 关闭

欢迎登录蓝色天空网

使用会员账号,继续你的学习