package analyzer import "testing" func TestTypedefUniqueErr (test *testing.T) { testStringErr (test, "Hello already declared at stream0.fspl:2:1", 3, 1, ` Hello: *Int Hello: (x:Int y:Int) `) } func TestTypedefUniqueErrShadowPrimitive (test *testing.T) { testStringErr (test, "cannot shadow primitive U8", 2, 1, ` U8: Int `) } func TestTypedefUniqueErrShadowBuiltin (test *testing.T) { testStringErr (test, "cannot shadow builtin String", 2, 1, ` String: Int `) } func TestTypedefUnique (test *testing.T) { testString (test, ` Hello: *Int World: (x:Int y:Int) `) } func TestTypedefRecursiveErr (test *testing.T) { testStringErr (test, "type List cannot be used in this context", 4, 9, ` List: ( value: Int next: List) `) } func TestTypedefRecursive (test *testing.T) { testString (test, ` List: ( value: Int next: *List) `) } func TestTypeNamedErrMissing (test *testing.T) { testStringErr (test, "no type named Missing", 2, 10, ` Present: Missing `) } func TestTypeNamed (test *testing.T) { testString (test, ` Example: Int AllBuiltin: ( int: Int uint: UInt byte: Byte rune: Rune string: String i8: I8 i16: I16 i32: I32 i64: I64 u8: U8 u16: U16 u32: U32 u64: U64 f32: F32 f64: F64 bool: Bool) [main] = { example:Example allBuiltin:AllBuiltin } `) } func TestTypePointer (test *testing.T) { testString (test, ` Ptr: *Int PtrPtr: **Int PtrPtrPtr: *PtrPtr ArrPtr: *5:Int SlicePtr: **:Int `) } func TestTypeSlice (test *testing.T) { testString (test, ` Slice: *:Int RaggedSlice: *:*:Int `) } func TestTypeArrayErrSizeZero (test *testing.T) { testStringErr (test, "array length must be > 0", 2, 8, ` Array: 0:Int `) } func TestTypeArray (test *testing.T) { testString (test, ` Array: 5:Int Matrix: 5:6:Int `) } func TestTypeStructMemberUniqueErr (test *testing.T) { testStringErr (test, "x already listed in struct at stream0.fspl:3:2", 6, 2, ` Bird: ( x:Int y:Int z:Int x:U8) `) } func TestTypeStructMemberUnique (test *testing.T) { testString (test, ` Bird: ( x:Int y:Int z:Int a:U8) `) } func TestTypeInterfaceBehaviorUniqueErr (test *testing.T) { testStringErr (test, "fly already listed in interface at stream0.fspl:2:8", 2, 14, ` Bird: ([fly] [fly]) `) } func TestTypeInterfaceBehaviorUnique (test *testing.T) { testString (test, ` Bird: ([fly] [land]) `) }