If I run my Powershell code for the Triangle exercise through Pester here on Exercism, 6 tests will pass, but 10 fail with:
Message: RuntimeException: Unable to find type [Triangle].
Stack-trace: at <ScriptBlock>, /mnt/exercism-iteration/Triangle.tests.ps1:9
If I copy the Pester test locally to my computer and run them, everything passes:
Tests Passed: 16, Failed: 0, Skipped: 0, Inconclusive: 0, NotRun: 0
Here’s my code in case it’s helpful:
Function Get-Triangle() {
<#
.SYNOPSIS
Determine if a triangle is equilateral, isosceles, or scalene.
.DESCRIPTION
Given 3 sides of a triangle, return the type of that triangle if it is a valid triangle.
.PARAMETER Sides
The lengths of a triangle's sides.
.EXAMPLE
Get-Triangle -Sides @(1,2,3)
Return: [Triangle]::SCALENE
#>
[CmdletBinding()]
Param (
[double[]]$Sides
)
Enum Triangle {
EQUILATERAL
ISOSCELES
SCALENE
}
$a = $Sides[0]
$b = $Sides[1]
$c = $Sides[2]
Write-Verbose "a [ $a ]; b [ $b ]; c [ $c ]"
if ( ($a -le 0) -or ($b -le 0) -or ($c -le 0) ) { throw "*All side lengths must be positive.*" }
if ( ($a+$b -ge $c) -and ($a+$c -ge $b) -and ($b+$c -ge $a) ) {
Write-Verbose "This is a triangle"
if ( $a -eq $b -and $a -eq $c ) {
[Triangle]::EQUILATERAL
} else {
if ( ($a -eq $b) -or ($a -eq $c) -or ($b -eq $c) ) {
[Triangle]::ISOSCELES
} else {
[Triangle]::SCALENE
}
}
} else {
throw "*Side lengths violate triangle inequality.*"
}
}
Any suggestions to try? If you need more info, please ask. This is my first time posting here on Exercism.