Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reorder stdlib tests w/ suggested style #3847

Merged
merged 7 commits into from
Oct 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 97 additions & 0 deletions STYLE_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -593,3 +593,100 @@ Single line comments will have exactly one space between the `//` token and the
// to coalesce multiple tiny arrays
// into a single bigger array
```

## Testing

### Ordering

Tests should be ordered alphabetically (within reason) separated into sections based on platform inclusion/exclusion criteria. First, list tests that run on all platforms, next list tests which include/exclude one platform, and lastly list tests which include/exclude multiple platforms. Sections should have an increasing number of inclusions/exclusions therefore if you have a section including only one platform, the next section should be tests excluding only that platform. When considering multiple platforms, list them alphabetically between sections and within sections. The set of known platforms recognized by `ifdef` can be found in `Platform` within `builtin`.

```pony
actor Main is TestList
new create(env: Env) => PonyTest(env, this)
new make() => None

fun tag tests(test: PonyTest) =>
// Tests below include all systems and are listed alphabetically
test(_TestOnAllSystemsA)
test(_TestOnAllSystemsB)
test(_TestOnAllSystemsC)

// Tests below include only bsd and are listed alphabetically
ifdef bsd then
test(_TestOnBsdA)
test(_TestOnBsdB)
test(_TestOnBsdC)
end

// Tests below exclude bsd and are listed alphabetically
ifdef not bsd then
test(_TestOnAllSystemsExceptBsdA)
test(_TestOnAllSystemsExceptBsdB)
test(_TestOnAllSystemsExceptBsdC)
end

// Tests below include only osx and are listed alphabetically
ifdef osx then
test(_TestOnOsxA)
test(_TestOnOsxB)
test(_TestOnOsxC)
end

// Tests below exclude osx and are listed alphabetically
ifdef not osx then
test(_TestOnAllSystemsExceptOsxA)
test(_TestOnAllSystemsExceptOsxB)
test(_TestOnAllSystemsExceptOsxC)
end

// Tests below include only windows and are listed alphabetically
ifdef windows then
test(_TestOnWindowsA)
test(_TestOnWindowsB)
test(_TestOnWindowsC)
end

// Tests below exclude windows and are listed alphabetically
ifdef not windows then
test(_TestOnAllSystemsExceptWindowsA)
test(_TestOnAllSystemsExceptWindowsB)
test(_TestOnAllSystemsExceptWindowsC)
end

// Tests below exclude bsd/windows and are listed alphabetically
ifdef not bsd or not windows then
test(_TestOnAllSystemsExceptBsdOrWindowsA)
test(_TestOnAllSystemsExceptBsdOrWindowsB)
test(_TestOnAllSystemsExceptBsdOrWindowsC)
end

// Tests below exclude osx/windows and are listed alphabetically
ifdef not osx or not windows then
test(_TestOnAllSystemsExceptOsxOrWindowsA)
test(_TestOnAllSystemsExceptOsxOrWindowsB)
test(_TestOnAllSystemsExceptOsxOrWindowsC)
end

// Tests below exclude bsd/osx/windows and are listed alphabetically
ifdef not bsd or not osx or not windows then
test(_TestOnAllSystemsExceptBsdOrOsxOrWindowsA)
test(_TestOnAllSystemsExceptBsdOrOsxOrWindowsB)
test(_TestOnAllSystemsExceptBsdOrOsxOrWindowsC)
end
```

It can sometimes make more sense to not use alphabetical ordering -- such as when using a generic test builder -- in such circumstances breaking alphabetical ordering is allowed.

```pony
actor Main is TestList
new create(env: Env) => PonyTest(env, this)
new make() => None

fun tag tests(test: PonyTest) =>
// Tests below include all systems and are listed in increasing type argument size
test(_TestOnAllSystemsWithBuilder[U8]())
test(_TestOnAllSystemsWithBuilder[U16]())
test(_TestOnAllSystemsWithBuilder[U32]())
test(_TestOnAllSystemsWithBuilder[U64]())
test(_TestOnAllSystemsWithBuilder[U128]())
```
3 changes: 1 addition & 2 deletions packages/buffered/_test.pony
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ actor Main is TestList
new make() => None

fun tag tests(test: PonyTest) =>
// Tests below function across all systems and are listed alphabetically
test(_TestReader)
test(_TestWriter)


class iso _TestReader is UnitTest
"""
Test adding to and reading from a Reader.
Expand Down Expand Up @@ -198,7 +198,6 @@ class iso _TestReader is UnitTest
// the last byte is consumed by the reader
h.assert_eq[USize](b.size(), 0)


class iso _TestWriter is UnitTest
"""
Test writing to and reading from a Writer.
Expand Down
125 changes: 63 additions & 62 deletions packages/builtin_test/_test.pony
Original file line number Diff line number Diff line change
Expand Up @@ -21,82 +21,83 @@ actor Main is TestList
new make() => None

fun tag tests(test: PonyTest) =>
// Tests below function across all systems and are listed alphabetically
test(_TestAbs)
test(_TestRotate)
test(_TestStringRunes)
test(_TestIntToString)
test(_TestFloatToString)
test(_TestStringToBool)
test(_TestStringToFloat)
test(_TestStringToU8)
test(_TestStringToI8)
test(_TestStringToIntLarge)
test(_TestStringLstrip)
test(_TestStringRstrip)
test(_TestStringStrip)
test(_TestStringStripNonAscii)
test(_TestStringRemove)
test(_TestStringSubstring)
test(_TestStringCut)
test(_TestStringTrim)
test(_TestStringTrimInPlace)
test(_TestStringTrimInPlaceWithAppend)
test(_TestStringIsNullTerminated)
test(_TestStringReplace)
test(_TestStringSplit)
test(_TestStringSplitBy)
test(_TestStringAdd)
test(_TestStringJoin)
test(_TestStringCount)
test(_TestStringCompare)
test(_TestStringContains)
test(_TestStringReadInt)
test(_TestStringUTF32)
test(_TestStringRFind)
test(_TestStringFromArray)
test(_TestStringFromIsoArray)
test(_TestStringSpace)
test(_TestStringRecalc)
test(_TestStringTruncate)
test(_TestStringChop)
test(_TestStringChopWithPush)
test(_TestStringUnchop)
test(_TestStringRepeatStr)
test(_TestStringConcatOffsetLen)
test(_TestStringFromCPointer)
test(_TestSpecialValuesF32)
test(_TestSpecialValuesF64)
test(_TestAddc)
test(_TestArrayAppend)
test(_TestArrayChop)
test(_TestArrayChopWithPush)
test(_TestArrayConcat)
test(_TestArrayFind)
test(_TestArrayFromCPointer)
test(_TestArrayInsert)
test(_TestArraySlice)
test(_TestArraySwapElements)
test(_TestArrayTrim)
test(_TestArrayTrimInPlace)
test(_TestArrayTrimInPlaceWithAppend)
test(_TestArrayInsert)
test(_TestArrayValuesRewind)
test(_TestArrayFind)
test(_TestArraySwapElements)
test(_TestArrayChop)
test(_TestArrayChopWithPush)
test(_TestArrayUnchop)
test(_TestArrayFromCPointer)
test(_TestArrayValuesRewind)
test(_TestDivc)
test(_TestFld)
test(_TestFldc)
test(_TestFloatToString)
test(_TestIntToString)
test(_TestLambdaCapture)
test(_TestMath128)
test(_TestRem)
test(_TestMod)
test(_TestFld)
test(_TestAddc)
test(_TestSubc)
test(_TestModc)
test(_TestMulc)
test(_TestDivc)
test(_TestFldc)
test(_TestNextPow2)
test(_TestNullablePointer)
test(_TestNumberConversionSaturation)
test(_TestRem)
test(_TestRemc)
test(_TestModc)
test(_TestRotate)
test(_TestSignedPartialArithmetic)
test(_TestSpecialValuesF32)
test(_TestSpecialValuesF64)
test(_TestStringAdd)
test(_TestStringChop)
test(_TestStringChopWithPush)
test(_TestStringCompare)
test(_TestStringConcatOffsetLen)
test(_TestStringContains)
test(_TestStringCount)
test(_TestStringCut)
test(_TestStringFromArray)
test(_TestStringFromCPointer)
test(_TestStringFromIsoArray)
test(_TestStringIsNullTerminated)
test(_TestStringJoin)
test(_TestStringLstrip)
test(_TestStringReadInt)
test(_TestStringRecalc)
test(_TestStringRemove)
test(_TestStringRepeatStr)
test(_TestStringReplace)
test(_TestStringRFind)
test(_TestStringRstrip)
test(_TestStringRunes)
test(_TestStringSpace)
test(_TestStringSplit)
test(_TestStringSplitBy)
test(_TestStringStrip)
test(_TestStringStripNonAscii)
test(_TestStringSubstring)
test(_TestStringToBool)
test(_TestStringToFloat)
test(_TestStringToI8)
test(_TestStringToIntLarge)
test(_TestStringToU8)
test(_TestStringTrim)
test(_TestStringTrimInPlace)
test(_TestStringTrimInPlaceWithAppend)
test(_TestStringTruncate)
test(_TestStringUnchop)
test(_TestStringUTF32)
test(_TestSubc)
test(_TestUnsignedPartialArithmetic)
test(_TestNextPow2)
test(_TestNumberConversionSaturation)
test(_TestNullablePointer)
test(_TestLambdaCapture)
test(_TestValtrace)

fun @runtime_override_defaults(rto: RuntimeOptions) =>
Expand Down
1 change: 1 addition & 0 deletions packages/bureaucracy/_test.pony
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ actor Main is TestList
new make() => None

fun tag tests(test: PonyTest) =>
// Tests below function across all systems and are listed alphabetically
test(_TestCustodian)
test(_TestRegistrar)

Expand Down
33 changes: 17 additions & 16 deletions packages/cli/_test.pony
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,31 @@ actor Main is TestList
new make() => None

fun tag tests(test: PonyTest) =>
test(_TestMinimal)
test(_TestMinimalWithHelp)
// Tests below function across all systems and are listed alphabetically
test(_TestBadName)
test(_TestUnknownCommand)
test(_TestUnexpectedArg)
test(_TestUnknownShort)
test(_TestUnknownLong)
test(_TestHyphenArg)
test(_TestBools)
test(_TestChat)
test(_TestDefaults)
test(_TestShortsAdj)
test(_TestShortsEq)
test(_TestShortsNext)
test(_TestLongsEq)
test(_TestLongsNext)
test(_TestEnvs)
test(_TestOptionStop)
test(_TestDuplicate)
test(_TestChat)
test(_TestMustBeLeaf)
test(_TestEnvs)
test(_TestHelp)
test(_TestHelpFalse)
test(_TestHelpMultipleArgs)
test(_TestHyphenArg)
test(_TestLongsEq)
test(_TestLongsNext)
test(_TestMinimal)
test(_TestMinimalWithHelp)
test(_TestMultipleEndOfOptions)
test(_TestMustBeLeaf)
test(_TestOptionStop)
test(_TestShortsAdj)
test(_TestShortsEq)
test(_TestShortsNext)
test(_TestUnexpectedArg)
test(_TestUnknownCommand)
test(_TestUnknownLong)
test(_TestUnknownShort)

class iso _TestMinimal is UnitTest
fun name(): String => "ponycli/minimal"
Expand Down
37 changes: 19 additions & 18 deletions packages/collections/_test.pony
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,32 @@ actor Main is TestList
new make() => None

fun tag tests(test: PonyTest) =>
// Tests below function across all systems and are listed alphabetically
test(_TestFlags)
test(_TestHashSetContains)
test(_TestHashSetIntersect)
test(_TestHeap)
test(_TestList)
test(_TestMap)
test(_TestMapRemove)
test(_TestMapUpsert)
test(_TestMapHashFunc)
test(_TestRing)
test(_TestListsFrom)
test(_TestListsMap)
test(_TestListsFlatMap)
test(_TestListsFilter)
test(_TestListsFold)
test(_TestListsContains)
test(_TestListsDrop)
test(_TestListsEvery)
test(_TestListsExists)
test(_TestListsFilter)
test(_TestListsFlatMap)
test(_TestListsFold)
test(_TestListsFrom)
test(_TestListsMap)
test(_TestListsPartition)
test(_TestListsDrop)
test(_TestListsReverse)
test(_TestListsTake)
test(_TestListsTakeWhile)
test(_TestListsContains)
test(_TestListsReverse)
test(_TestHashSetContains)
test(_TestHashSetIntersect)
test(_TestSort)
test(_TestMap)
test(_TestMapHashFunc)
test(_TestMapRemove)
test(_TestMapUpsert)
test(_TestRange)
test(_TestHeap)
test(_TestFlags)
test(_TestRing)
test(_TestSort)

class iso _TestList is UnitTest
fun name(): String => "collections/List"
Expand Down
Loading