Skip to documentation
SLOP

tiny.smg.cli.facts

Reference tiny.smg cli facts

Defined in cli.

API (2)

Actions

Public operations.

No direct callersNo direct callsclifacts
Static calls · unresolved targets: unknown · external targets: unknown.

Source

Called byCallsNo direct callscli.factsvalueTextcli.jsonwriteFactValuecli.factsfloatText
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallstest; no linktools.smg.src.cli.factstest: fact value text preserves integ...private; no linktools.smg.src.command.check.renderpredicateWitnessTextcli.factsfloatTextcli.factsvalueText
Static calls · unresolved targets: 0 · external targets: 0.

Source: tools/smg/src/cli/facts.zig

zig
const std = @import("std");const smg = @import("../root.zig");const rules = smg.rules;pub fn valueText(allocator: std.mem.Allocator, value: rules.FactValue) ![]const u8 {    return switch (value) {        .number => |number| if (number == @floor(number)) try std.fmt.allocPrint(allocator, "{d}", .{@as(i64, @intFromFloat(number))}) else try std.fmt.allocPrint(allocator, "{d}", .{number}),        .float_number => |number| try floatText(allocator, number),        .boolean => |boolean| if (boolean) "true" else "false",    };}pub fn floatText(allocator: std.mem.Allocator, number: f64) ![]const u8 {    if (number == @floor(number)) return try std.fmt.allocPrint(allocator, "{d:.1}", .{number});    return try std.fmt.allocPrint(allocator, "{d}", .{number});}test "fact value text preserves integer and float spellings" {    const allocator = std.testing.allocator;    const int_text = try valueText(allocator, .{ .number = 7 });    defer allocator.free(int_text);    try std.testing.expectEqualStrings("7", int_text);    const float_text = try valueText(allocator, .{ .float_number = 7 });    defer allocator.free(float_text);    try std.testing.expectEqualStrings("7.0", float_text);    const fractional_text = try valueText(allocator, .{ .float_number = 7.25 });    defer allocator.free(fractional_text);    try std.testing.expectEqualStrings("7.25", fractional_text);    try std.testing.expectEqualStrings("true", try valueText(allocator, .{ .boolean = true }));}

Source: tools/smg/src/cli/root.zig:2

zig
pub const facts = @import("facts.zig");

Audit

Definitions3
Public names3
Members0
Version26.7.0
Revisiondaab053ee433