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
can be generated with properties from docblocks. For this, several additional
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
[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
* This module provides geometry related functions.
*
* @property-bootstrap
* import StdReal, StdInt
* derive class Gast Angle
* import StdReal, StdInt
* derive class Gast Angle
*
* // there is a tradeoff between the largest degree value allowed and the error
* angleInvariant :: Angle -> Property
* angleInvariant angle = prop (abs (toDeg angle) <= 1.0E6)
* // there is a tradeoff between the largest degree value allowed and the error
* angleInvariant :: Angle -> Property
* angleInvariant angle = prop (abs (toDeg angle) <= 1.0E6)
*
* (~~) infix 4
* (~~) x y :== approxEqual 1.0E-11 x y
* (~~) infix 4
* (~~) x y :== approxEqual 1.0E-11 x y
*/
from StdEnv import class ==, class <, class +, class -, class sign, class abs
......@@ -33,7 +33,7 @@ pi :== 3.14159265359
* @param the radian representation
* @result the corresponding angle
* @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
......@@ -43,7 +43,7 @@ rad :: !Real -> Angle
* @param the degree representation
* @result the corresponding angle
* @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
......@@ -53,7 +53,7 @@ deg :: !Real -> Angle
* @param the angle
* @result the angle's degree representation
* @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
*/
toDeg :: !Angle -> Real
......@@ -64,7 +64,7 @@ toDeg :: !Angle -> Real
* @param the angle
* @result the angle's radian representation
* @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
*/
toRad :: !Angle -> Real
......@@ -75,15 +75,15 @@ toRad :: !Angle -> Real
* @param the angle to normalize
* @result the normalized angle
* @property normalized degree range: A.angle :: Angle:
* 0.0 <=. degNorm /\ degNorm <=. 360.0
* with
* degNorm = toDeg (normalize angle)
* 0.0 <=. degNorm /\ degNorm <=. 360.0
* with
* degNorm = toDeg (normalize angle)
* @property normalized radian range: A.angle :: Angle:
* 0.0 <=. radNorm /\ radNorm <=. 2.0 * pi
* with
* radNorm = toRad (normalize angle)
* 0.0 <=. radNorm /\ radNorm <=. 2.0 * pi
* with
* radNorm = toRad (normalize angle)
* @property idempotence: A.angle :: Angle:
* normalize angle =.= normalize (normalize angle)
* normalize angle =.= normalize (normalize angle)
* @precondition angleInvariant angle
*/
normalize :: !Angle -> Angle
......
......@@ -4,25 +4,25 @@ definition module System.FilePath
* Module for manipulation of file and directory paths
*
* @property-bootstrap
* import StdEnv, Text
* import StdEnv, Text
*
* :: GFilePath :== [GFilePathPart]
* :: GFilePathPart = PathSep | ExtSep | Name GName
* :: GName = A | B | C | D
* :: GFilePath :== [GFilePathPart]
* :: GFilePathPart = PathSep | ExtSep | Name GName
* :: GName = A | B | C | D
*
* derive genShow GFilePathPart, GName
* derive ggen GFilePathPart, GName
* derive gPrint GFilePathPart, GName
* derive genShow GFilePathPart, GName
* derive ggen GFilePathPart, GName
* derive gPrint GFilePathPart, GName
*
* @property-test-generator GFilePath -> FilePath
* gen gfp = concat (map toString gfp)
* where
* toString PathSep = {pathSeparator}
* toString ExtSep = {extSeparator}
* toString (Name A) = "a"
* toString (Name B) = "ab"
* toString (Name C) = "abc"
* toString (Name D) = "abcd"
* gen gfp = concat (map toString gfp)
* where
* toString PathSep = {pathSeparator}
* toString ExtSep = {extSeparator}
* toString (Name A) = "a"
* toString (Name B) = "ab"
* toString (Name C) = "abc"
* toString (Name D) = "abcd"
*/
from Data.Error import :: MaybeError
......@@ -54,16 +54,16 @@ extSeparator :: Char
* Split a FilePath into filename and extension. The result does not include the extension separator (.).
*
* @property no separators in extension: A.fp :: FilePath:
* let
* (fname,ext`) = splitExtension fp
* ext = [c \\ c <-: ext`] in
* not (isMember extSeparator ext) /\
* not (isMember pathSeparator ext)
* let
* (fname,ext`) = splitExtension fp
* ext = [c \\ c <-: ext`] in
* not (isMember extSeparator ext) /\
* not (isMember pathSeparator ext)
*
* @property identity with addExtension: A.fp :: FilePath:
* let (fname,ext) = splitExtension fp in
* not (endsWith {extSeparator} fname) ==>
* addExtension fname ext =.= fp
* let (fname,ext) = splitExtension fp in
* not (endsWith {extSeparator} fname) ==>
* addExtension fname ext =.= fp
*/
splitExtension :: !FilePath -> (String, String)
......
......@@ -6,8 +6,8 @@ definition module Text.Encodings.Base64
* - http://en.wikipedia.org/wiki/Base64
*
* @property-bootstrap
* import StdEnv
* import Text
* import StdEnv
* import Text
*/
:: Length :== Int
......@@ -18,32 +18,32 @@ definition module Text.Encodings.Base64
/**
* Converts a String to a Base64-encoded String.
* @property inverse: A.x :: String:
* base64Decode (base64Encode x) == x
* base64Decode (base64Encode x) == x
*/
base64Encode :: !.String -> .String
/**
* Converts a String to a Base64-encoded String given a maximum line length.
* @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:
* 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
/**
* Converts a String to an URL-safe Base64-encoded String.
* @property inverse: A.x :: String:
* base64URLDecode (base64URLEncode x) == x
* base64URLDecode (base64URLEncode x) == x
*/
base64URLEncode :: !.String -> .String
/**
* Converts a String to an URL-safe Base64-encoded String given a maximum line length.
* @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:
* 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
......@@ -60,17 +60,17 @@ base64URLDecode :: !.String -> .String
/**
* Decodes a Base64-encoded String in place.
* @property inverse: A.x :: String:
* base64DecodeUnique (base64Encode x) == x
* base64DecodeUnique (base64Encode x) == x
* @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
/**
* Decodes a URL-safe Base64-encoded String in place.
* @property inverse: A.x :: String:
* base64URLDecodeUnique (base64URLEncode x) == x
* base64URLDecodeUnique (base64URLEncode x) == x
* @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
......@@ -9,7 +9,7 @@ definition module Text.GenJSON
* For more info about JSON see: http://www.json.org/
*
* @property-bootstrap
* import StdEnv
* import StdEnv
*/
import StdGeneric
......@@ -49,17 +49,17 @@ derive gEq JSONNode
* Encodes any value to JSON format.
*
* @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=Bool
* @property-test-with type=Char
* @property-test-with type=String
*
* @property correctness Real: A.a :: Real:
* toString (toReal (toString a)) == toString a ==>
* case fromJSON (fromString (toString (toJSON a))) of
* Nothing -> prop False
* Just b -> if (isNaN a) (prop (isNaN b)) (toString a =.= fromReal b)
* toString (toReal (toString a)) == toString a ==>
* case fromJSON (fromString (toString (toJSON a))) of
* Nothing -> prop False
* Just b -> if (isNaN a) (prop (isNaN b)) (toString a =.= fromReal b)
*
* @param The value to encode
* @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