Skip to content

Commit

Permalink
exercises: stubs: resolve unused parameter errors (#195)
Browse files Browse the repository at this point in the history
Before this commit, when testing an unchanged exercise stub:

    $ zig test test_leap.zig
    leap.zig:1:19: error: unused function parameter
    pub fn isLeapYear(year: u32) bool {
                      ^~~~

With this commit:

    $ zig test test_leap.zig
    Test [1/9] test.year not divisible by 4 in common year... thread 123456 panic: please implement the isLeapYear function
    /foo/exercism-tracks/zig/exercises/practice/leap/leap.zig:3:5: 0x201234 in isLeapYear (test)
        @Panic("please implement the isLeapYear function");
    [...]

Closes: #175
  • Loading branch information
ee7 authored Mar 2, 2023
1 parent 39f4bc9 commit 39194db
Show file tree
Hide file tree
Showing 15 changed files with 46 additions and 0 deletions.
2 changes: 2 additions & 0 deletions exercises/practice/binary-search/binary_search.zig
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Take a look at the tests, you might have to change the function arguments

pub fn binarySearch(target: usize, buffer: ?[]const usize) SearchError!usize {
_ = target;
_ = buffer;
@panic("please implement the binarySearch function");
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pub fn steps(number: isize) anyerror!usize {
_ = number;
@panic("please implement the steps function");
}
3 changes: 3 additions & 0 deletions exercises/practice/darts/darts.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ pub const Coordinate = struct {
// This struct, as well as its fields and methods, needs to be implemented.

pub fn init(x_coord: f32, y_coord: f32) Coordinate {
_ = x_coord;
_ = y_coord;
@panic("please implement the init method");
}
pub fn score(self: Coordinate) isize {
_ = self;
@panic("please implement the score method");
}
};
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
pub fn squareOfSum(number: isize) isize {
_ = number;
@panic("compute the sum of i from 0 to n then square it");
}

pub fn sumOfSquares(number: isize) isize {
_ = number;
@panic("compute the sum of i^2 from 0 to n");
}

pub fn differenceOfSquares(number: isize) isize {
_ = number;
@panic("compute the difference between the square of sum and sum of squares");
}
1 change: 1 addition & 0 deletions exercises/practice/grains/grains.zig
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pub fn square(index: isize) ChessboardError!u64 {
_ = index;
@panic("please implement the square function");
}

Expand Down
2 changes: 2 additions & 0 deletions exercises/practice/hamming/hamming.zig
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
pub fn compute(first: []const u8, second: []const u8) DnaError!usize {
_ = first;
_ = second;
@panic("please implement the compute function");
}
1 change: 1 addition & 0 deletions exercises/practice/isogram/isogram.zig
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pub fn isIsogram(str: []const u8) bool {
_ = str;
@panic("please implement the isIsogram function");
}
1 change: 1 addition & 0 deletions exercises/practice/leap/leap.zig
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pub fn isLeapYear(year: u32) bool {
_ = year;
@panic("please implement the isLeapYear function");
}
1 change: 1 addition & 0 deletions exercises/practice/pangram/pangram.zig
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pub fn isPangram(str: []const u8) bool {
_ = str;
@panic("please implement the isPangram function");
}
2 changes: 2 additions & 0 deletions exercises/practice/proverb/proverb.zig
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
pub fn recite(allocator: mem.Allocator, words: []const []const u8) (fmt.AllocPrintError || mem.Allocator.Error)![][]u8 {
_ = allocator;
_ = words;
@panic("please implement the recite function");
}
2 changes: 2 additions & 0 deletions exercises/practice/rna-transcription/rna_transcription.zig
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Import the appropriate standard library and modules

pub fn toRna(allocator: mem.Allocator, dna: []const u8) (RnaError || mem.Allocator.Error)![]const u8 {
_ = allocator;
_ = dna;
@panic("please implement the toRna function");
}
2 changes: 2 additions & 0 deletions exercises/practice/secret-handshake/secret_handshake.zig
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
pub fn calculateHandshake(allocator: mem.Allocator, number: isize) mem.Allocator.Error![]const Signal {
_ = allocator;
_ = number;
@panic("please implement the calculateHandshake function");
}
11 changes: 11 additions & 0 deletions exercises/practice/space-age/space_age.zig
Original file line number Diff line number Diff line change
Expand Up @@ -5,46 +5,57 @@ pub const SpaceAge = struct {
// implemented.

pub fn init(seconds: isize) SpaceAge {
_ = seconds;
@panic("please implement the init method");
}

fn getOrbitalPeriodInSecondsFromEarthYearsOf(planet: Planet) f64 {
_ = planet;
@panic("please implement the getOrbitalPeriodInSecondsFromEarthYearsOf method");
}

fn getOrbitalPeriodInEarthYearsOf(planet: Planet) f64 {
_ = planet;
@panic("please implement the getOrbitalPeriodInEarthYearsOf method");
}

pub fn onMercury(self: SpaceAge) f64 {
_ = self;
@panic("please implement the onMercury method");
}

pub fn onVenus(self: SpaceAge) f64 {
_ = self;
@panic("please implement the onVenus method");
}

pub fn onEarth(self: SpaceAge) f64 {
_ = self;
@panic("please implement the onEarth method");
}

pub fn onMars(self: SpaceAge) f64 {
_ = self;
@panic("please implement the onMars method");
}

pub fn onJupiter(self: SpaceAge) f64 {
_ = self;
@panic("please implement the onJupiter method");
}

pub fn onSaturn(self: SpaceAge) f64 {
_ = self;
@panic("please implement the onSaturn method");
}

pub fn onUranus(self: SpaceAge) f64 {
_ = self;
@panic("please implement the onUranus method");
}

pub fn onNeptune(self: SpaceAge) f64 {
_ = self;
@panic("please implement the onNeptune method");
}
};
12 changes: 12 additions & 0 deletions exercises/practice/triangle/triangle.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,38 @@ pub const Triangle = struct {
// This struct, as well as its fields and methods, needs to be implemented.

pub fn init(first: f64, second: f64, third: f64) TriangleError!Triangle {
_ = first;
_ = second;
_ = third;
@panic("please implement the init method");
}

fn verifyIfDegenerateAttributesExist(first: f64, second: f64, third: f64) TriangleError!void {
_ = first;
_ = second;
_ = third;
@panic("optional verifyIfDegenerateAttributesExist method");
}

fn verifyIfTriangleInequalityHolds(first: f64, second: f64, third: f64) TriangleError!void {
_ = first;
_ = second;
_ = third;
@panic("please implement the verifyIfTriangleInequalityHolds method");
}

pub fn isEquilateral(self: Triangle) bool {
_ = self;
@panic("please implement the isEquilateral method");
}

pub fn isIsosceles(self: Triangle) bool {
_ = self;
@panic("please implement the isIsosceles method");
}

pub fn isScalene(self: Triangle) bool {
_ = self;
@panic("please implement the isScalene method");
}
};
2 changes: 2 additions & 0 deletions exercises/practice/two-fer/two_fer.zig
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
pub fn twoFer(buffer: []u8, name: ?[]const u8) anyerror![]u8 {
_ = buffer;
_ = name;
@panic("respond with the appropriate message given a particular name");
}

0 comments on commit 39194db

Please sign in to comment.