Verified Commit 5560d110 authored by Camil Staps's avatar Camil Staps 🚀

Use four spaces for indentation in properties

parent 0e731357
Pipeline #29625 passed with stage
in 2 minutes and 48 seconds
...@@ -96,6 +96,18 @@ With [clean-test-properties][]' `testproperties` tool, [Gast][] test programs ...@@ -96,6 +96,18 @@ With [clean-test-properties][]' `testproperties` tool, [Gast][] test programs
can be generated with properties from docblocks. For this, several additional can be generated with properties from docblocks. For this, several additional
fields can be used, which are further documented by [clean-test-properties][]. fields can be used, which are further documented by [clean-test-properties][].
Our [standards](STANDARDS.md) require the use of tabs for indentation and spaces
for outlining. Because with properties code is included in documentation blocks,
using tabs for indentation would lead to tabs after spaces. To avoid this, we
use four spaces in this context instead. For example:
```clean
/**
* @property correctness: A.xs :: Set a:
* minList (toList xs) == findMin xs
*/
```
[clean-test-properties]: https://gitlab.science.ru.nl/clean-and-itasks/clean-test-properties [clean-test-properties]: https://gitlab.science.ru.nl/clean-and-itasks/clean-test-properties
[Gast]: https://gitlab.science.ru.nl/clean-and-itasks/gast [Gast]: https://gitlab.science.ru.nl/clean-and-itasks/gast
......
This diff is collapsed.
This diff is collapsed.
...@@ -4,15 +4,15 @@ definition module Math.Geometry ...@@ -4,15 +4,15 @@ definition module Math.Geometry
* This module provides geometry related functions. * This module provides geometry related functions.
* *
* @property-bootstrap * @property-bootstrap
* import StdReal, StdInt * import StdReal, StdInt
* derive class Gast Angle * derive class Gast Angle
* *
* // there is a tradeoff between the largest degree value allowed and the error * // there is a tradeoff between the largest degree value allowed and the error
* angleInvariant :: Angle -> Property * angleInvariant :: Angle -> Property
* angleInvariant angle = prop (abs (toDeg angle) <= 1.0E6) * angleInvariant angle = prop (abs (toDeg angle) <= 1.0E6)
* *
* (~~) infix 4 * (~~) infix 4
* (~~) x y :== approxEqual 1.0E-11 x y * (~~) x y :== approxEqual 1.0E-11 x y
*/ */
from StdEnv import class ==, class <, class +, class -, class sign, class abs from StdEnv import class ==, class <, class +, class -, class sign, class abs
...@@ -33,7 +33,7 @@ pi :== 3.14159265359 ...@@ -33,7 +33,7 @@ pi :== 3.14159265359
* @param the radian representation * @param the radian representation
* @result the corresponding angle * @result the corresponding angle
* @property correct angle from radian: A.r :: Real: * @property correct angle from radian: A.r :: Real:
* not (isNaN r) ==> r =.= toRad (rad r) * not (isNaN r) ==> r =.= toRad (rad r)
*/ */
rad :: !Real -> Angle rad :: !Real -> Angle
...@@ -43,7 +43,7 @@ rad :: !Real -> Angle ...@@ -43,7 +43,7 @@ rad :: !Real -> Angle
* @param the degree representation * @param the degree representation
* @result the corresponding angle * @result the corresponding angle
* @property correct angle from degrees: A.d :: Real: * @property correct angle from degrees: A.d :: Real:
* not (isNaN d) ==> d =.= toDeg (deg d) * not (isNaN d) ==> d =.= toDeg (deg d)
*/ */
deg :: !Real -> Angle deg :: !Real -> Angle
...@@ -53,7 +53,7 @@ deg :: !Real -> Angle ...@@ -53,7 +53,7 @@ deg :: !Real -> Angle
* @param the angle * @param the angle
* @result the angle's degree representation * @result the angle's degree representation
* @property degrees from angle agree with radians: A.angle :: Angle: * @property degrees from angle agree with radians: A.angle :: Angle:
* toDeg angle ~~ toDeg (rad (toRad angle)) * toDeg angle ~~ toDeg (rad (toRad angle))
* @precondition angleInvariant angle * @precondition angleInvariant angle
*/ */
toDeg :: !Angle -> Real toDeg :: !Angle -> Real
...@@ -64,7 +64,7 @@ toDeg :: !Angle -> Real ...@@ -64,7 +64,7 @@ toDeg :: !Angle -> Real
* @param the angle * @param the angle
* @result the angle's radian representation * @result the angle's radian representation
* @property radians from angle agree with degrees: A.angle :: Angle: * @property radians from angle agree with degrees: A.angle :: Angle:
* toRad angle ~~ toRad (deg (toDeg angle)) * toRad angle ~~ toRad (deg (toDeg angle))
* @precondition angleInvariant angle * @precondition angleInvariant angle
*/ */
toRad :: !Angle -> Real toRad :: !Angle -> Real
...@@ -75,15 +75,15 @@ toRad :: !Angle -> Real ...@@ -75,15 +75,15 @@ toRad :: !Angle -> Real
* @param the angle to normalize * @param the angle to normalize
* @result the normalized angle * @result the normalized angle
* @property normalized degree range: A.angle :: Angle: * @property normalized degree range: A.angle :: Angle:
* 0.0 <=. degNorm /\ degNorm <=. 360.0 * 0.0 <=. degNorm /\ degNorm <=. 360.0
* with * with
* degNorm = toDeg (normalize angle) * degNorm = toDeg (normalize angle)
* @property normalized radian range: A.angle :: Angle: * @property normalized radian range: A.angle :: Angle:
* 0.0 <=. radNorm /\ radNorm <=. 2.0 * pi * 0.0 <=. radNorm /\ radNorm <=. 2.0 * pi
* with * with
* radNorm = toRad (normalize angle) * radNorm = toRad (normalize angle)
* @property idempotence: A.angle :: Angle: * @property idempotence: A.angle :: Angle:
* normalize angle =.= normalize (normalize angle) * normalize angle =.= normalize (normalize angle)
* @precondition angleInvariant angle * @precondition angleInvariant angle
*/ */
normalize :: !Angle -> Angle normalize :: !Angle -> Angle
......
...@@ -4,25 +4,25 @@ definition module System.FilePath ...@@ -4,25 +4,25 @@ definition module System.FilePath
* Module for manipulation of file and directory paths * Module for manipulation of file and directory paths
* *
* @property-bootstrap * @property-bootstrap
* import StdEnv, Text * import StdEnv, Text
* *
* :: GFilePath :== [GFilePathPart] * :: GFilePath :== [GFilePathPart]
* :: GFilePathPart = PathSep | ExtSep | Name GName * :: GFilePathPart = PathSep | ExtSep | Name GName
* :: GName = A | B | C | D * :: GName = A | B | C | D
* *
* derive genShow GFilePathPart, GName * derive genShow GFilePathPart, GName
* derive ggen GFilePathPart, GName * derive ggen GFilePathPart, GName
* derive gPrint GFilePathPart, GName * derive gPrint GFilePathPart, GName
* *
* @property-test-generator GFilePath -> FilePath * @property-test-generator GFilePath -> FilePath
* gen gfp = concat (map toString gfp) * gen gfp = concat (map toString gfp)
* where * where
* toString PathSep = {pathSeparator} * toString PathSep = {pathSeparator}
* toString ExtSep = {extSeparator} * toString ExtSep = {extSeparator}
* toString (Name A) = "a" * toString (Name A) = "a"
* toString (Name B) = "ab" * toString (Name B) = "ab"
* toString (Name C) = "abc" * toString (Name C) = "abc"
* toString (Name D) = "abcd" * toString (Name D) = "abcd"
*/ */
from Data.Error import :: MaybeError from Data.Error import :: MaybeError
...@@ -54,16 +54,16 @@ extSeparator :: Char ...@@ -54,16 +54,16 @@ extSeparator :: Char
* Split a FilePath into filename and extension. The result does not include the extension separator (.). * Split a FilePath into filename and extension. The result does not include the extension separator (.).
* *
* @property no separators in extension: A.fp :: FilePath: * @property no separators in extension: A.fp :: FilePath:
* let * let
* (fname,ext`) = splitExtension fp * (fname,ext`) = splitExtension fp
* ext = [c \\ c <-: ext`] in * ext = [c \\ c <-: ext`] in
* not (isMember extSeparator ext) /\ * not (isMember extSeparator ext) /\
* not (isMember pathSeparator ext) * not (isMember pathSeparator ext)
* *
* @property identity with addExtension: A.fp :: FilePath: * @property identity with addExtension: A.fp :: FilePath:
* let (fname,ext) = splitExtension fp in * let (fname,ext) = splitExtension fp in
* not (endsWith {extSeparator} fname) ==> * not (endsWith {extSeparator} fname) ==>
* addExtension fname ext =.= fp * addExtension fname ext =.= fp
*/ */
splitExtension :: !FilePath -> (String, String) splitExtension :: !FilePath -> (String, String)
......
...@@ -6,8 +6,8 @@ definition module Text.Encodings.Base64 ...@@ -6,8 +6,8 @@ definition module Text.Encodings.Base64
* - http://en.wikipedia.org/wiki/Base64 * - http://en.wikipedia.org/wiki/Base64
* *
* @property-bootstrap * @property-bootstrap
* import StdEnv * import StdEnv
* import Text * import Text
*/ */
:: Length :== Int :: Length :== Int
...@@ -18,32 +18,32 @@ definition module Text.Encodings.Base64 ...@@ -18,32 +18,32 @@ definition module Text.Encodings.Base64
/** /**
* Converts a String to a Base64-encoded String. * Converts a String to a Base64-encoded String.
* @property inverse: A.x :: String: * @property inverse: A.x :: String:
* base64Decode (base64Encode x) == x * base64Decode (base64Encode x) == x
*/ */
base64Encode :: !.String -> .String base64Encode :: !.String -> .String
/** /**
* Converts a String to a Base64-encoded String given a maximum line length. * Converts a String to a Base64-encoded String given a maximum line length.
* @property inverse: A.len :: Int; x :: String: * @property inverse: A.len :: Int; x :: String:
* len > 0 ==> base64Decode (base64EncodeLen x len) == x * len > 0 ==> base64Decode (base64EncodeLen x len) == x
* @property max length: A.len :: Int; x :: String: * @property max length: A.len :: Int; x :: String:
* len > 0 ==> all ((>=) len o size) (split "\n" (base64EncodeLen x len)) * len > 0 ==> all ((>=) len o size) (split "\n" (base64EncodeLen x len))
*/ */
base64EncodeLen :: !.String !Length -> .String base64EncodeLen :: !.String !Length -> .String
/** /**
* Converts a String to an URL-safe Base64-encoded String. * Converts a String to an URL-safe Base64-encoded String.
* @property inverse: A.x :: String: * @property inverse: A.x :: String:
* base64URLDecode (base64URLEncode x) == x * base64URLDecode (base64URLEncode x) == x
*/ */
base64URLEncode :: !.String -> .String base64URLEncode :: !.String -> .String
/** /**
* Converts a String to an URL-safe Base64-encoded String given a maximum line length. * Converts a String to an URL-safe Base64-encoded String given a maximum line length.
* @property inverse: A.len :: Int; x :: String: * @property inverse: A.len :: Int; x :: String:
* len > 0 ==> base64URLDecode (base64URLEncodeLen x len) == x * len > 0 ==> base64URLDecode (base64URLEncodeLen x len) == x
* @property max length: A.len :: Int; x :: String: * @property max length: A.len :: Int; x :: String:
* len > 0 ==> all ((>=) len o size) (split "\n" (base64URLEncodeLen x len)) * len > 0 ==> all ((>=) len o size) (split "\n" (base64URLEncodeLen x len))
*/ */
base64URLEncodeLen :: !.String !Length -> .String base64URLEncodeLen :: !.String !Length -> .String
...@@ -60,17 +60,17 @@ base64URLDecode :: !.String -> .String ...@@ -60,17 +60,17 @@ base64URLDecode :: !.String -> .String
/** /**
* Decodes a Base64-encoded String in place. * Decodes a Base64-encoded String in place.
* @property inverse: A.x :: String: * @property inverse: A.x :: String:
* base64DecodeUnique (base64Encode x) == x * base64DecodeUnique (base64Encode x) == x
* @property inverse with linebreaks: A.len :: Int; x :: String: * @property inverse with linebreaks: A.len :: Int; x :: String:
* len > 0 ==> base64DecodeUnique (base64EncodeLen x len) == x * len > 0 ==> base64DecodeUnique (base64EncodeLen x len) == x
*/ */
base64DecodeUnique :: !*String -> .String base64DecodeUnique :: !*String -> .String
/** /**
* Decodes a URL-safe Base64-encoded String in place. * Decodes a URL-safe Base64-encoded String in place.
* @property inverse: A.x :: String: * @property inverse: A.x :: String:
* base64URLDecodeUnique (base64URLEncode x) == x * base64URLDecodeUnique (base64URLEncode x) == x
* @property inverse with linebreaks: A.len :: Int; x :: String: * @property inverse with linebreaks: A.len :: Int; x :: String:
* len > 0 ==> base64URLDecodeUnique (base64URLEncodeLen x len) == x * len > 0 ==> base64URLDecodeUnique (base64URLEncodeLen x len) == x
*/ */
base64URLDecodeUnique :: !*String -> .String base64URLDecodeUnique :: !*String -> .String
...@@ -9,7 +9,7 @@ definition module Text.GenJSON ...@@ -9,7 +9,7 @@ definition module Text.GenJSON
* For more info about JSON see: http://www.json.org/ * For more info about JSON see: http://www.json.org/
* *
* @property-bootstrap * @property-bootstrap
* import StdEnv * import StdEnv
*/ */
import StdGeneric import StdGeneric
...@@ -49,17 +49,17 @@ derive gEq JSONNode ...@@ -49,17 +49,17 @@ derive gEq JSONNode
* Encodes any value to JSON format. * Encodes any value to JSON format.
* *
* @property correctness: A.a :: type: * @property correctness: A.a :: type:
* maybe (prop False) ((=.=) a) (fromJSON (fromString (toString (toJSON a)))) * maybe (prop False) ((=.=) a) (fromJSON (fromString (toString (toJSON a))))
* @property-test-with type=Int * @property-test-with type=Int
* @property-test-with type=Bool * @property-test-with type=Bool
* @property-test-with type=Char * @property-test-with type=Char
* @property-test-with type=String * @property-test-with type=String
* *
* @property correctness Real: A.a :: Real: * @property correctness Real: A.a :: Real:
* toString (toReal (toString a)) == toString a ==> * toString (toReal (toString a)) == toString a ==>
* case fromJSON (fromString (toString (toJSON a))) of * case fromJSON (fromString (toString (toJSON a))) of
* Nothing -> prop False * Nothing -> prop False
* Just b -> if (isNaN a) (prop (isNaN b)) (toString a =.= fromReal b) * Just b -> if (isNaN a) (prop (isNaN b)) (toString a =.= fromReal b)
* *
* @param The value to encode * @param The value to encode
* @return The JSON encoded value * @return The JSON encoded value
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment