├── debian ├── compat ├── install ├── copyright ├── rules └── control ├── test ├── lipsum.txt ├── .gitignore ├── error │ ├── LexLiteralStringEndOfFile.fu │ ├── FieldVoid.fu │ ├── LexUtf8High.fu │ ├── FieldStatic.fu │ ├── LexCommentMultiLineUnterminated.fu │ ├── LexUtf8Overlong.fu │ ├── ArrayStgHugeLength.fu │ ├── LexUtf8NoContinuation2.fu │ ├── ArrayStgNegativeLength.fu │ ├── ArrayStgStringLength.fu │ ├── MethodNoReturnType.fu │ ├── ToplevelVar.fu │ ├── ConstructorSealed.fu │ ├── ConstructorStatic.fu │ ├── ConstructorVirtual.fu │ ├── ConstructorAbstract.fu │ ├── ConstructorOverride.fu │ ├── ConstructorParameters2.fu │ ├── ConstructorStaticClass.fu │ ├── OpModZero.fu │ ├── MainNotStatic.fu │ ├── MethodPrivateAbstract.fu │ ├── ClassBaseUndefined.fu │ ├── MainPrivate.fu │ ├── StReturnNoValue.fu │ ├── ExprList.fu │ ├── LexInvalidChar.fu │ ├── MethodBaseNoBase.fu │ ├── TypeClassInc.fu │ ├── MethodNoReturn.fu │ ├── StBreakInvalid.fu │ ├── StContinueInvalid.fu │ ├── StReturnType.fu │ ├── LexInvalidDollar.fu │ ├── MethodPrivateVirtual.fu │ ├── MethodStaticMutating.fu │ ├── StSwitchNoCases.fu │ ├── ExprRange.fu │ ├── LexLiteralDecTrailingUnderscore.fu │ ├── MethodCallNotFound.fu │ ├── MethodDuplicate.fu │ ├── StReturnVoidValue.fu │ ├── ConstructorDuplicate.fu │ ├── EnumFlagsNoValue.fu │ ├── LexLiteralHexTrailingUnderscore.fu │ ├── MethodAbstractClassNormal.fu │ ├── MethodParamDefaultNonConst.fu │ ├── MethodParamDefaultTypeMismatch.fu │ ├── OpAssignMethod.fu │ ├── TypeIntPtr.fu │ ├── TypeRangeFloat.fu │ ├── ConstructorParameters.fu │ ├── DocCodeUnterminated.fu │ ├── LexLiteralCharEmpty.fu │ ├── LexLiteralDecTrailingLetters.fu │ ├── MainParamInt.fu │ ├── MathSinUnknown.fu │ ├── ObjectInitNotField.fu │ ├── ObjectStgNotClass.fu │ ├── OpExclamationMark.fu │ ├── OpIndexInt.fu │ ├── PreElseUnmatched.fu │ ├── PreEndifUnmatched.fu │ ├── PreIfUnterminated.fu │ ├── UnreachableNative.fu │ ├── UnreachableReturn.fu │ ├── IntNullable.fu │ ├── LambdaUnexpected.fu │ ├── LexLiteralHexTrailingLetters.fu │ ├── MethodNonstaticClassStatic.fu │ ├── PreElifUnmatched.fu │ ├── TypeRangeMaxMin.fu │ ├── ArrayStgVarLength.fu │ ├── LexLiteralCharInvalid.fu │ ├── LexLiteralCharInvalidEscape.fu │ ├── MethodVirtualClassSealed.fu │ ├── OpEqualBoolInt.fu │ ├── ClassBaseInternal.fu │ ├── ConstArrayReadWrite.fu │ ├── LexLiteralCharUnterminated.fu │ ├── LexLiteralDecOverflow2.fu │ ├── MethodOverrideNotFound.fu │ ├── OpEqualStringInt.fu │ ├── StringInterpolatedArgError.fu │ ├── TypeRangeMaxLimit.fu │ ├── FieldInitThrows.fu │ ├── LexLiteralFloatUnderscoreExp.fu │ ├── MainReturnFloat.fu │ ├── OpIndexObject.fu │ ├── StForeachUndefined.fu │ ├── TypeRangeMinLimit.fu │ ├── ConstNameNotId.fu │ ├── LexLiteralDecOverflow.fu │ ├── LexLiteralHexOverflow.fu │ ├── LexResourceSyntax3.fu │ ├── OpAssignLiteral.fu │ ├── OpSelectTypeMismatch.fu │ ├── PreElseUnterminated.fu │ ├── ResourceNameInt.fu │ ├── TypeStringSize.fu │ ├── LexLiteralFloatFractUnderscoreExp.fu │ ├── LexLiteralStringEndOfLine.fu │ ├── OpEqualStringStgNull.fu │ ├── OpIndexStringBounds.fu │ ├── OpPostDecRightCondOr.fu │ ├── OpPreIncRightCondAnd.fu │ ├── PreElseElse.fu │ ├── PreElseElse2.fu │ ├── UnreachableWhile.fu │ ├── ConstArrayLengthMismatch.fu │ ├── ConstValueBase.fu │ ├── MainParams.fu │ ├── MethodBaseNotFound.fu │ ├── OpAndAssignDouble.fu │ ├── PreElseElif.fu │ ├── PreElseElif2.fu │ ├── SymbolDuplicate.fu │ ├── ConstIntAggregateInitializer.fu │ ├── MethodCallTooManyArgs.fu │ ├── PreElseGarbage.fu │ ├── StAssertMessageNotString.fu │ ├── StForeachClass.fu │ ├── UnreachableDoWhile.fu │ ├── UnreachableFor.fu │ ├── VarInitAssign.fu │ ├── ConstNonConst.fu │ ├── LexLiteralLeadingZero.fu │ ├── MethodCallTooFewArgs.fu │ ├── OpAddStringBool.fu │ ├── OpAndFloat.fu │ ├── PreEndifGarbage.fu │ ├── StForeachInt.fu │ ├── StNativeUnterminated.fu │ ├── DynamicObjectLeakInit.fu │ ├── StForUninitializedInit.fu │ ├── OpEqualArrayStgInt.fu │ ├── ClassBaseCircular.fu │ ├── DynamicArrayLeakInit.fu │ ├── LexLiteralBinOverflow.fu │ ├── OpAddAssignStringObjectStg.fu │ ├── OpAddVoid.fu │ ├── OpAssignTrailingId.fu │ ├── ArrayReadOnlyPtrModify.fu │ ├── ConsoleWriteObjectPtr.fu │ ├── MainDuplicate.fu │ ├── MethodBaseNotMethod.fu │ ├── MethodParamNameNotId.fu │ ├── MethodPrivateOverride.fu │ ├── StSwitchValueNotFound.fu │ ├── MethodOverrideNormal.fu │ ├── MethodOverrideReturnTypeMismatch.fu │ ├── StForeachArrayStgTypeMismatch.fu │ ├── StForeachStringInString.fu │ ├── MethodShortReturn.fu │ ├── OpIndexArrayBounds.fu │ ├── PreExprInvalid.fu │ ├── StForeachArrayStgKeyValue.fu │ ├── DictionaryAddNotStg.fu │ ├── DynamicObjectLeakReturn.fu │ ├── ListStringSort.fu │ ├── ObjectStgBang.fu │ ├── OpIncDecCondExp.fu │ ├── PreIfUnterminated2.fu │ ├── StThrowNoThrows.fu │ ├── AssignForeachVar.fu │ ├── ObjectStgCopy.fu │ ├── StSwitchCaseEndOfFile.fu │ ├── VisibilityPrivateConst.fu │ ├── ConstCircular.fu │ ├── DynamicArrayLeakReturn.fu │ ├── LexLiteralFloatTrailingLetters.fu │ ├── MethodBaseStatic.fu │ ├── OpIsBase.fu │ ├── StThrowNonString.fu │ ├── VisibilityPrivateFieldStorage.fu │ ├── ConsoleWriteLineArrayStg.fu │ ├── OpIsReadOnlyReadWrite.fu │ ├── OpOrEnumNoFlags.fu │ ├── StSwitchCaseNotConst.fu │ ├── TypeNotFound.fu │ ├── UnreachableIf.fu │ ├── VisibilityPrivateMethodDerived.fu │ ├── DynamicObjectInitLeakInit.fu │ ├── VarUninitialized.fu │ ├── MethodCallMutatingOnReadOnlyPtr.fu │ ├── StSwitchCaseType.fu │ ├── VisibilityPrivateFieldDerivedStorage.fu │ ├── VisibilityPrivateFieldPtr.fu │ ├── ConstNonConstEnum.fu │ ├── DynamicObjectLeakArgument.fu │ ├── MethodOverrideParameterTypeMismatch.fu │ ├── OpNewInt.fu │ ├── VisibilityPrivateMethodDerivedPtr.fu │ ├── ArrayPtrNullable.fu │ ├── ReturnDanglingPtrToObjectStg.fu │ ├── StSwitchCaseNullWhenInvalid.fu │ ├── StSwitchDefaultEndOfFile.fu │ ├── DynamicArrayLeakArgument.fu │ ├── MethodCallMutatingFromNonMutating.fu │ ├── StForeachDictionaryNoKeyValue.fu │ ├── VisibilityProtectedFieldBaseStorage.fu │ ├── LexResourceSyntax2.fu │ ├── ListTwoTypeArgs.fu │ ├── ReturnDanglingPtrToArrayStg.fu │ ├── StSwitchCaseDefault.fu │ ├── MethodCallError.fu │ ├── OpIsUnrelated.fu │ ├── StSwitchCaseFallthrough.fu │ ├── SymbolGlobalInside.fu │ ├── VisibilityPrivateFieldBase.fu │ ├── ReturnDanglingPtrToStringStg.fu │ ├── StForeachDictionaryKeyTypeMismatch.fu │ ├── StForeachDictionaryValueTypeMismatch.fu │ ├── SymbolUnknown.fu │ ├── VisibilityPrivateFieldDerivedPtr.fu │ ├── VisibilityPrivateMethodBase.fu │ ├── StSwitchDefaultFallthrough.fu │ ├── VisibilityProtectedFieldNotDerived.fu │ ├── ClassStaticInstance.fu │ ├── DynamicArrayLeakSelect.fu │ ├── StSwitchFloat.fu │ ├── StringInterpolatedArgUnknownMethod.fu │ ├── LexLiteralFloatInvalid.fu │ ├── MethodCallStaticWithInstance.fu │ ├── UnreachableSwitch.fu │ ├── LexResourceSyntax1.fu │ ├── MethodCallNoThrows.fu │ ├── ThisInvalid.fu │ ├── OpNotEqualStgDynamic.fu │ ├── OpIsNotClass.fu │ ├── TypeNames.fu │ ├── ClassAbstractInstance.fu │ ├── MethodOverrideMutatingMismatch.fu │ ├── MethodOverrideParameterCountMismatch.fu │ ├── StringInterpolatedFormatError.fu │ ├── OpIsNotPtr.fu │ ├── PreUnknown.fu │ ├── StringAssignNull.fu │ └── BaseMemberDuplicate.fu ├── LexGolf.fu ├── MethodShort.fu ├── Basic.fu ├── LexLiteralHex.fu ├── OpParentheses.fu ├── LexLiteralDec.fu ├── LexLiteralOctal.fu ├── Namespace.fu ├── PreIf.fu ├── PreNot.fu ├── PreOr.fu ├── PreUndefined.fu ├── NativeTopLevel.fu ├── PreAnd.fu ├── ListDynamic.fu ├── PreElse.fu ├── ConstBool.fu ├── IntUnsigned.fu ├── LexLiteralBin.fu ├── MathNaN.fu ├── OpPostDec.fu ├── OpPreInc.fu ├── PreParentheses.fu ├── StringPtrNullable.fu ├── ConstDouble.fu ├── ObjectPtrCycle.fu ├── OpDivAssignInt.fu ├── LexCommentMultiLine.fu ├── LexCommentSingleLine.fu ├── MathFloor.fu ├── OpCondAnd.fu ├── PreCommentSingleLine.fu ├── StNative.fu ├── ConstForwardMethod.fu ├── MainVoid.fu ├── MathCeiling.fu ├── MathPI.fu ├── OpComplement.fu ├── StDoWhile.fu ├── StIf.fu ├── StringStartsWith2.fu ├── tsconfig.json ├── DoubleTryParse.fu ├── OpIndexArrayStg.fu ├── StReturnStringNull.fu ├── StWhile.fu ├── OpAddStringInterpolated.fu ├── OpDivDouble.fu ├── OpNotEqualString2.fu ├── PreElseIf.fu ├── StForFloat.fu ├── ConstInt.fu ├── PreEqual.fu ├── StackOfPtr.fu ├── StringReplace.fu ├── LexLiteralCharUnicode.fu ├── MethodParamByte.fu ├── OpPreIncWhile.fu ├── PreNotEqual.fu ├── StElse.fu ├── OpIndexArrayPtr.fu ├── StForeachString.fu ├── ClassForwardBase.fu ├── ConstString.fu ├── HashSetOfPtr.fu ├── OpPreDecDoWhile.fu ├── PreStringInterpolated.fu ├── Lock.fu ├── MathE.fu ├── OpPostIncDoWhile.fu ├── StElseIf.fu ├── EnumToInt.fu ├── FloatToInt.fu ├── ObjectFieldArrayStg.fu ├── RegexOptions.fu ├── StBreakFor.fu ├── StringStg.fu ├── ClassForwardStg.fu ├── MathCos.fu ├── MathLog.fu ├── MathSin.fu ├── MathTan.fu ├── ObjectConstructor.fu ├── OpEqualArrayPtr.fu ├── ArrayStgContains.fu ├── MathAcos.fu ├── MathAsin.fu ├── MathAtan.fu ├── MathCosh.fu ├── MathLog2.fu ├── MathSinh.fu ├── MathSqrt.fu ├── MathTanh.fu ├── ObjectFieldProtected.fu ├── OpField.fu ├── OpNotEqualArrayPtr.fu ├── StringSubstringZero.fu ├── ConsoleErrorWrite.fu ├── ConsoleErrorWriteCodePoint.fu ├── DynamicReset.fu ├── MathLog10.fu ├── MethodParamAssign.fu ├── ObjectFieldInit.fu ├── StBreakWhile.fu ├── StReturn.fu ├── DynamicArrayStringStg.fu ├── EnumFromInt.fu ├── ListLast.fu ├── cs.runtimeconfig.json ├── ArrayLength.fu ├── DynamicArrayByte.fu ├── MathCbrt.fu ├── StForRangeStep.fu ├── LexLiteralString.fu ├── MathTruncate.fu ├── MethodThis.fu ├── ObjectInit.fu ├── OpEqualNum.fu ├── StReturnDestruct.fu ├── ListListPtr.fu ├── OpAddNum.fu ├── OpIndexString.fu ├── OpSub.fu ├── Range.fu ├── StReturnConstructor.fu ├── StringStgInitPtr.fu ├── ConstByteArray.fu ├── Double.fu ├── MathRound.fu ├── OpEqualNull.fu ├── OpGreater.fu ├── RegexEscape.fu ├── StElseMethodStatic.fu ├── StNativeInclude.fu ├── StSwitchArrayElement.fu ├── StringToLowerUpperMaxMin.fu ├── MathIsNaN.fu ├── MethodCallFromConstructor.fu ├── MethodProtected.fu ├── OpNeg.fu ├── OpPostInc.fu ├── StSwitch.fu ├── StSwitchByte.fu ├── package.json ├── MathPow.fu ├── MethodArgTempDynamic.fu ├── MethodVoid.fu ├── OpPreDec.fu ├── ArrayInt.fu ├── EncodingGetByteCount.fu ├── LongTryParse.fu ├── MathAtan2.fu ├── OpPostIncIf.fu ├── OpBitAssignByte.fu ├── StForeachHashSet.fu ├── DynamicDictionary.fu ├── LexLiteralDouble.fu ├── ListOfPtr.fu ├── Long.fu ├── OpEqualBool.fu ├── OpIsDynamic.fu ├── ClassForwardPtr.fu ├── ObjectDestructorBase.fu ├── OpAddAssignString.fu ├── Resource.fu ├── summary.pl ├── ConstFloat.fu ├── ObjectConstructorBase.fu ├── OpNotEqualNull.fu ├── StSwitchStringStg.fu ├── ArrayStgContainsPtr.fu ├── ConstLong.fu ├── OpLessOrEqual.fu ├── OpPostIncReturn.fu ├── StBlock.fu ├── ObjectToString.fu ├── OpDivInt.fu ├── OpMod.fu ├── EnumValue.fu ├── MathExp.fu ├── OpNotEqualNum.fu ├── ConsoleWrite.fu ├── OpPostIncWhile.fu ├── ArrayStgInit.fu ├── StBreakSwitch.fu ├── DictionaryDynamicList.fu ├── EnumLess.fu ├── MethodStatic.fu ├── ObjectFieldPublic.fu ├── ObjectPtrToStg.fu ├── StSwitchField.fu ├── StackPtr.fu ├── LexLiteralChar.fu ├── OpNot.fu ├── StReturnObjectStg.fu ├── TempNoBlock.fu ├── ArrayStgStringStg.fu ├── ConsoleWriteLineSubstring.fu ├── StSwitchSubstring.fu ├── DictionaryList.fu ├── ExceptionSubclass.fu ├── IntTryParse.fu ├── MethodAbstract.fu ├── ObjectConstructorGrand.fu ├── OpNotEqualString.fu ├── OpPostIncFor.fu ├── OpPreIncIf.fu ├── PreDocApostrophe.fu ├── QueuePtr.fu ├── StringSubstringTemporary.fu ├── Float.fu ├── ObjectPtrToDynamic.fu ├── OpLess.fu ├── SortedDictionaryList.fu ├── StAssertCast.fu ├── StThrowDestruct.fu ├── Dictionary.fu ├── OpCondOr.fu ├── DictionaryDynamic.fu ├── DynamicInit.fu ├── OpEqualString.fu ├── SortedDictionary.fu ├── StringInterpolatedSubstring.fu ├── ConsoleErrorWriteLine.fu ├── MethodShortIsVar.fu ├── RegexMatchReuse.fu ├── ArrayStgInitField.fu ├── HashSetPtr.fu ├── MathFusedMultiplyAdd.fu ├── MathInfinity.fu ├── StForRangeDec.fu ├── StForeachListPtr.fu ├── StSwitchVarStringStg.fu ├── MethodArgTempObjectStg.fu ├── OpIsVar.fu ├── StReturnThrows.fu ├── CollectionPtrCycle.fu ├── DictionaryPtr.fu ├── MethodSealed.fu ├── StringSubstring2.fu ├── ArrayPtrMultiDim.fu ├── StContinueWhile.fu ├── StringInterpolatedTemporary.fu ├── PreElif.fu ├── StForeachDictionary.fu ├── ArrayListPtr.fu ├── DynamicAssign.fu ├── ListObjectStg.fu ├── OpAddString.fu ├── OpIsVarDynamic.fu ├── StIfIsVar.fu ├── DynamicArrayMultiDim.fu ├── IntMinMaxValue.fu ├── ListList.fu ├── Stack.fu ├── DictionaryObjectStg.fu ├── MethodArgTempObjectStgDestructor.fu ├── MethodParamDefault.fu ├── ConstEnum.fu ├── ObjectPtrToBase.fu ├── ListDictionary.fu ├── ListStack.fu ├── OpGreaterOrEqual.fu ├── OpIs.fu ├── StAssertCastDynamic.fu ├── StContinueDoWhile.fu ├── StFor.fu ├── ConsoleWriteLine.fu ├── ListAll.fu ├── ListObjectStgDestr.fu ├── SortedDictionaryObjectStg.fu ├── ClassAbstractDerived.fu ├── EncodingGetString.fu ├── ListSortedDictionary.fu ├── StSwitchUTF8.fu ├── ArrayStgDynamic.fu ├── EncodingGetBytes.fu ├── MathMaxMin.fu ├── MethodOverride.fu ├── OpBoolLogic.fu ├── StReturnDynamic.fu ├── StringEndsWith.fu ├── MethodOverrideForward.fu ├── MethodParamObjectStg.fu ├── MethodVirtualThrows.fu ├── DictionaryObjectStgPublicConstructor.fu ├── OpMul.fu ├── StAssert.fu ├── MathAbs.fu ├── OpIsVarIf.fu ├── ListArrayStg.fu ├── DictionaryDictionary.fu ├── StForNotRange.fu └── StSwitchVar.fu ├── editors ├── vim │ └── ftdetect │ │ └── fusion.vim ├── vscode │ ├── .gitignore │ ├── fu-logo.png │ ├── .vscodeignore │ ├── fu-file.svg │ └── tsconfig.json └── vs │ └── languages.pkgdef ├── win32 └── setup │ ├── .gitignore │ ├── fu.ico │ ├── banner.png │ └── dialog.png ├── .gitignore ├── package.json ├── AssemblyInfo.cs └── fut.csproj /debian/compat: -------------------------------------------------------------------------------- 1 | 10 2 | -------------------------------------------------------------------------------- /debian/install: -------------------------------------------------------------------------------- 1 | usr/bin/fut 2 | -------------------------------------------------------------------------------- /test/lipsum.txt: -------------------------------------------------------------------------------- 1 | Lorem ipsum dolor sit amet -------------------------------------------------------------------------------- /test/.gitignore: -------------------------------------------------------------------------------- 1 | /cpp 2 | /cs 3 | /java 4 | /node 5 | /node_modules 6 | -------------------------------------------------------------------------------- /test/error/LexLiteralStringEndOfFile.fu: -------------------------------------------------------------------------------- 1 | "//ERROR: Unterminated string literal -------------------------------------------------------------------------------- /editors/vim/ftdetect/fusion.vim: -------------------------------------------------------------------------------- 1 | au BufRead,BufNewFile *.fu set filetype=fusion 2 | -------------------------------------------------------------------------------- /test/LexGolf.fu: -------------------------------------------------------------------------------- 1 | public static class Test{public static bool Run(){return true;}} -------------------------------------------------------------------------------- /editors/vscode/.gitignore: -------------------------------------------------------------------------------- 1 | /fusion-*.vsix 2 | /node_modules 3 | /out 4 | /src/fucheck.js 5 | -------------------------------------------------------------------------------- /win32/setup/.gitignore: -------------------------------------------------------------------------------- 1 | /*.msi 2 | /*.wixobj 3 | /*.wixpdb 4 | /signed 5 | /signed-msi 6 | -------------------------------------------------------------------------------- /win32/setup/fu.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fusionlanguage/fut/HEAD/win32/setup/fu.ico -------------------------------------------------------------------------------- /win32/setup/banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fusionlanguage/fut/HEAD/win32/setup/banner.png -------------------------------------------------------------------------------- /win32/setup/dialog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fusionlanguage/fut/HEAD/win32/setup/dialog.png -------------------------------------------------------------------------------- /test/MethodShort.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() => true; 4 | } 5 | -------------------------------------------------------------------------------- /test/error/FieldVoid.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | void Foo; //ERROR: Field cannot be void 4 | } 5 | -------------------------------------------------------------------------------- /editors/vs/languages.pkgdef: -------------------------------------------------------------------------------- 1 | [$RootKey$\TextMate\Repositories] 2 | "fusion"="$PackageFolder$\syntaxes" 3 | -------------------------------------------------------------------------------- /editors/vscode/fu-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fusionlanguage/fut/HEAD/editors/vscode/fu-logo.png -------------------------------------------------------------------------------- /test/error/LexUtf8High.fu: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fusionlanguage/fut/HEAD/test/error/LexUtf8High.fu -------------------------------------------------------------------------------- /test/error/FieldStatic.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | static int Foo; //ERROR: Field cannot be static 4 | } 5 | -------------------------------------------------------------------------------- /test/error/LexCommentMultiLineUnterminated.fu: -------------------------------------------------------------------------------- 1 | /* 2 | //ERROR: Unterminated multi-line comment, started in line 1 -------------------------------------------------------------------------------- /test/error/LexUtf8Overlong.fu: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fusionlanguage/fut/HEAD/test/error/LexUtf8Overlong.fu -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .vs 2 | .vscode 3 | bin 4 | obj 5 | /coverage 6 | /fut 7 | /fut.exe 8 | /java 9 | /Properties 10 | -------------------------------------------------------------------------------- /editors/vscode/.vscodeignore: -------------------------------------------------------------------------------- 1 | .gitignore 2 | Makefile 3 | src/extension.ts 4 | src/fucheck.js 5 | tsconfig.json 6 | -------------------------------------------------------------------------------- /test/Basic.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | return true; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/error/ArrayStgHugeLength.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | int[10000000000] Array; //ERROR: Integer too big 4 | } 5 | -------------------------------------------------------------------------------- /test/error/LexUtf8NoContinuation2.fu: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fusionlanguage/fut/HEAD/test/error/LexUtf8NoContinuation2.fu -------------------------------------------------------------------------------- /test/error/ArrayStgNegativeLength.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | int[-5] Array; //ERROR: Expected non-negative integer 4 | } 5 | -------------------------------------------------------------------------------- /test/error/ArrayStgStringLength.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | int["foo"] Array; //ERROR: Cannot convert 'string' to 'int' 4 | } 5 | -------------------------------------------------------------------------------- /test/error/MethodNoReturnType.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | public Tester() { //ERROR: Method with no return type 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/error/ToplevelVar.fu: -------------------------------------------------------------------------------- 1 | int x; //ERROR: Expected class or enum //ERROR: Expected class or enum //ERROR: Expected class or enum 2 | -------------------------------------------------------------------------------- /test/LexLiteralHex.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | return 0xc0dE == 49374; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/OpParentheses.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | return 2 * (2 + 3) == 10; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/error/ConstructorSealed.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | public sealed Test() { //ERROR: Constructor cannot be sealed 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/error/ConstructorStatic.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | public static Test() { //ERROR: Constructor cannot be static 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/LexLiteralDec.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | return 1_000_000 == 1000000; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/LexLiteralOctal.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | return 0o370132 == 127066; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/Namespace.fu: -------------------------------------------------------------------------------- 1 | public static class Test //FAIL: cpp TODO; cl 2 | { 3 | public static bool Run() 4 | { 5 | return true; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/error/ConstructorVirtual.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | public virtual Test() { //ERROR: Constructor cannot be virtual 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/error/ConstructorAbstract.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | public abstract Test() { //ERROR: Constructor cannot be abstract 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/error/ConstructorOverride.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | public override Test() { //ERROR: Constructor cannot be override 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/error/ConstructorParameters2.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | public Test(Test) { //ERROR: Constructor parameters not supported 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/error/ConstructorStaticClass.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public Test() { //ERROR: Constructor in a static class 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/error/OpModZero.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | return 5 % 0; //ERROR: Mod zero 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/error/MainNotStatic.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | public void Main() //ERROR: 'Main' method must be 'public static' 4 | { 5 | } 6 | } 7 | 8 | -------------------------------------------------------------------------------- /test/error/MethodPrivateAbstract.fu: -------------------------------------------------------------------------------- 1 | public abstract class Test 2 | { 3 | abstract //ERROR: Private method cannot be abstract 4 | bool Run(); 5 | } 6 | -------------------------------------------------------------------------------- /test/PreIf.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | #if true 6 | return true; 7 | #endif 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/PreNot.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | #if !false 6 | return true; 7 | #endif 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/PreOr.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | #if FOO || true 6 | return true; 7 | #endif 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/PreUndefined.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | #if !FOO 6 | return true; 7 | #endif 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/error/ClassBaseUndefined.fu: -------------------------------------------------------------------------------- 1 | public class Test : 2 | Base //ERROR: Base class 'Base' not found 3 | { 4 | public static bool Run() => true; 5 | } 6 | -------------------------------------------------------------------------------- /test/error/MainPrivate.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | static void Main() //ERROR: 'Main' method must be 'public static' 4 | { 5 | } 6 | } 7 | 8 | -------------------------------------------------------------------------------- /test/error/StReturnNoValue.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | return; //ERROR: Missing return value 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/NativeTopLevel.fu: -------------------------------------------------------------------------------- 1 | native { 2 | } 3 | 4 | public static class Test 5 | { 6 | public static bool Run() 7 | { 8 | return true; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/PreAnd.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | #if true && !false 6 | return true; 7 | #endif 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/error/ExprList.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int i = List(); //ERROR: Invalid expression 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/error/LexInvalidChar.fu: -------------------------------------------------------------------------------- 1 | public static @class Test //ERROR: Invalid character 2 | { 3 | public static bool Run() 4 | { 5 | return true; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/error/MethodBaseNoBase.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | bool Foo() => base.Bar(); //ERROR: No base class 4 | 5 | public static bool Run() => true; 6 | } 7 | -------------------------------------------------------------------------------- /test/error/TypeClassInc.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | public static bool Run() 4 | { 5 | Test++ p; //ERROR: Invalid type 6 | return true; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/ListDynamic.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | public static bool Run() 4 | { 5 | List() list; //FAIL: cl 6 | return list.Count == 0; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/PreElse.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | #if false 6 | #else 7 | return true; 8 | #endif 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/error/MethodNoReturn.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() //ERROR: Method can complete without a return value 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /test/error/StBreakInvalid.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | break; //ERROR: 'break' outside loop or 'switch' 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/error/StContinueInvalid.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | continue; //ERROR: 'continue' outside loop 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/error/StReturnType.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | return int; //ERROR: 'int' is not an expression 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/ConstBool.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public const bool Foo = true; 4 | 5 | public static bool Run() 6 | { 7 | return Foo; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/IntUnsigned.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int i = 0xea << 24; 6 | return ((i >> 24) & 0xff) == 0xea; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/LexLiteralBin.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | return 0b00101011010 == 346 6 | && 0b_1_0101_1010 == 346; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/MathNaN.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | return Math.IsNaN(Math.NaN) 6 | && !Math.IsFinite(Math.NaN); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/error/LexInvalidDollar.fu: -------------------------------------------------------------------------------- 1 | $public static class Test //ERROR: Expected interpolated string 2 | { 3 | public static bool Run() 4 | { 5 | return true; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/error/MethodPrivateVirtual.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | virtual //ERROR: Private method cannot be virtual 4 | bool Run() 5 | { 6 | return true; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/error/MethodStaticMutating.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run!() //ERROR: Expected '(', got '!' 4 | { 5 | return true; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/error/StSwitchNoCases.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | switch (42) { 6 | } //ERROR: Switch with no cases 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/error/ExprRange.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | 5 .. 10; //ERROR: Range within an expression 6 | return true; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/error/LexLiteralDecTrailingUnderscore.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | return 5_ == 5; //ERROR: Invalid integer 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/error/MethodCallNotFound.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | Foo(); //ERROR: 'Foo' not found 6 | return true; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/error/MethodDuplicate.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() => true; 4 | public static bool Run() => true; //ERROR: Duplicate symbol 5 | } 6 | -------------------------------------------------------------------------------- /test/error/StReturnVoidValue.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static void Run() 4 | { 5 | return true; //ERROR: Void method cannot return a value 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/OpPostDec.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int a = 42; 6 | int b = a--; 7 | return a == 41 && b == 42; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/OpPreInc.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int a = 42; 6 | int b = ++a; 7 | return a == 43 && b == 43; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/PreParentheses.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | #if true && (false || true) 6 | return true; 7 | #endif 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/StringPtrNullable.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | public static bool Run() 4 | { 5 | string? s = "foo"; 6 | string n = s; 7 | return n == "foo"; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/error/ConstructorDuplicate.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | public Test() { 4 | } 5 | public Test() { //ERROR: Duplicate constructor, already defined in line 3 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/error/EnumFlagsNoValue.fu: -------------------------------------------------------------------------------- 1 | enum* DaysOfWeek 2 | { 3 | Sunday, //ERROR: enum* symbol must be assigned a value 4 | Monday 5 | } //ERROR: enum* symbol must be assigned a value 6 | -------------------------------------------------------------------------------- /test/error/LexLiteralHexTrailingUnderscore.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | return 0x0_ == 0; //ERROR: Invalid integer 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/error/MethodAbstractClassNormal.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | protected 4 | abstract //ERROR: Abstract methods allowed only in an abstract class 5 | bool Run(); 6 | } 7 | -------------------------------------------------------------------------------- /test/error/MethodParamDefaultNonConst.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static void Run(int[]# arr = new int[10]) //ERROR: Expected constant value 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /test/error/MethodParamDefaultTypeMismatch.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static void Run(int x = 5.0) //ERROR: Cannot convert 'double' to 'int' 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /test/error/OpAssignMethod.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | Run = false; //ERROR: Cannot modify this 6 | return true; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/error/TypeIntPtr.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | public static bool Run() 4 | { 5 | int! p; //ERROR: Unexpected '!' on a non-reference type 6 | return true; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/error/TypeRangeFloat.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | 0 .. 10.5 i = 0; //ERROR: Expected integer 6 | return true; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/ConstDouble.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public const double Foo = -10.5; 4 | 5 | public static bool Run() 6 | { 7 | return Foo == -10.5; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/ObjectPtrCycle.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | Test? Ref; 4 | 5 | public static bool Run() 6 | { 7 | Test() o; 8 | o.Ref = o; 9 | return true; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/OpDivAssignInt.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int a = 7; 6 | int b = 3; 7 | a /= b; 8 | return a == 2; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/error/ConstructorParameters.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | public Test(int foo) { //ERROR: Expected ')', got identifier //ERROR: Constructor parameters not supported 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/error/DocCodeUnterminated.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | /// Returns `true //ERROR: Unterminated code in documentation comment 4 | public static bool Run() => true; 5 | } 6 | -------------------------------------------------------------------------------- /test/error/LexLiteralCharEmpty.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int a = ''; //ERROR: Empty character literal 6 | return true; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/error/LexLiteralDecTrailingLetters.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | 0 .. 0foo; //ERROR: Invalid integer 6 | return true; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/error/MainParamInt.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static void Main( 4 | int argc) //ERROR: 'Main' method parameter must be 'string[]' 5 | { 6 | } 7 | } 8 | 9 | -------------------------------------------------------------------------------- /test/error/MathSinUnknown.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static double Foo(bar x) //ERROR: Type 'bar' not found 4 | { 5 | return Math.Sin(x / 4); 6 | } 7 | } 8 | 9 | -------------------------------------------------------------------------------- /test/error/ObjectInitNotField.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | public static bool Run() 4 | { 5 | Test() o = { Run = 3 }; //ERROR: Expected a field 6 | return true; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/error/ObjectStgNotClass.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | public static bool Run() 4 | { 5 | string() o; //ERROR: 'string' is not a class 6 | return true; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/error/OpExclamationMark.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int factorial = 5!; //ERROR: Unexpected '!' 6 | return true; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/error/OpIndexInt.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int i = 1["foo"]; //ERROR: Cannot index this object 6 | return true; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/error/PreElseUnmatched.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | #else //ERROR: '#else' with no matching '#if' 6 | return true; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/error/PreEndifUnmatched.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | #endif //ERROR: '#endif' with no matching '#if' 6 | return true; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/error/PreIfUnterminated.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | #if true 6 | return true; 7 | } 8 | } //ERROR: Expected '#endif', got end-of-file -------------------------------------------------------------------------------- /test/error/UnreachableNative.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | return true; 6 | native { ; } //ERROR: Unreachable statement 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/error/UnreachableReturn.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | return true; 6 | return false; //ERROR: Unreachable statement 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/LexCommentMultiLine.fu: -------------------------------------------------------------------------------- 1 | /* comment 1 2 | comment 2 */ 3 | public static class Test 4 | { 5 | public static bool Run() 6 | { 7 | return/* comment 3 */true; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/LexCommentSingleLine.fu: -------------------------------------------------------------------------------- 1 | // comment 1 2 | // comment 2 3 | public static class Test 4 | { 5 | public static bool Run() 6 | { 7 | return true; // comment 3 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/MathFloor.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | double a = 1.75; //FAIL: cl if no double support 6 | return Math.Floor(a) == 1; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/OpCondAnd.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | bool a = false; 6 | int[]? b = null; 7 | return !(a && b[0] == 0); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/PreCommentSingleLine.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | #if true // comment 1 6 | return true; 7 | #endif // comment 2 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/StNative.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int a; 6 | a = 1; 7 | native {a = 42; 8 | } 9 | return a == 42; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/error/IntNullable.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int? i = 42; //ERROR: Nullable value types not supported 6 | return true; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/error/LambdaUnexpected.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | x => x + 1; //ERROR: Unexpected lambda expression 6 | return true; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/error/LexLiteralHexTrailingLetters.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | 0 .. 0xfoo; //ERROR: Invalid integer 6 | return true; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/error/MethodNonstaticClassStatic.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public bool Run() //ERROR: Only static methods allowed in a static class 4 | { 5 | return true; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/error/PreElifUnmatched.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | #elif true //ERROR: '#elif' with no matching '#if' 6 | return true; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/error/TypeRangeMaxMin.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | 5 .. 3 i = 3; //ERROR: Range min greater than max 6 | return true; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/ConstForwardMethod.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | return Foo(42); 6 | } 7 | 8 | static bool Foo(int answer) => answer == 42; 9 | } 10 | -------------------------------------------------------------------------------- /test/MainVoid.fu: -------------------------------------------------------------------------------- 1 | public static class Runner 2 | { 3 | public static void Main() //FAIL: cl 4 | { 5 | int i = 42; 6 | if (i == 42) 7 | return; 8 | assert false; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/MathCeiling.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | double a = 1.25; //FAIL: cl if no double support 6 | return Math.Ceiling(a) == 2; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/MathPI.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | double pi = Math.PI; //FAIL: cl if no double support 6 | return pi > 3.14 && pi < 3.15; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/OpComplement.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int a = 42; 6 | byte b = 1; 7 | return ~a == -43 8 | && ~b == ~1; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/StDoWhile.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int i = 0; 6 | do 7 | i++; 8 | while (i < 0); 9 | return i == 1; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/StIf.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int a = 1; 6 | int b = 2; 7 | if (a == 1) 8 | b++; 9 | return b == 3; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/error/ArrayStgVarLength.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | public bool Run() 4 | { 5 | int x = 5; 6 | int[x] a; //ERROR: Expected constant value 7 | return true; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/error/LexLiteralCharInvalid.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int a = ' '; //ERROR: Invalid character in literal 6 | return true; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/error/LexLiteralCharInvalidEscape.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int a = '\d'; //ERROR: Unknown escape sequence 6 | return true; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/error/MethodVirtualClassSealed.fu: -------------------------------------------------------------------------------- 1 | public sealed class Test 2 | { 3 | public virtual bool Run() //ERROR: Virtual methods disallowed in a sealed class 4 | { 5 | return true; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/error/OpEqualBoolInt.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int i = 0; 6 | return false == i; //ERROR: Cannot compare 'bool' with 'int' 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/StringStartsWith2.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | public static bool Run() 4 | { 5 | string p = "foobar"; 6 | return p.StartsWith("f") 7 | && p.StartsWith("foo"); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/error/ClassBaseInternal.fu: -------------------------------------------------------------------------------- 1 | class Base 2 | { 3 | } 4 | 5 | public class Test : Base //ERROR: Public class cannot derive from an internal class 6 | { 7 | public static bool Run() => true; 8 | } 9 | -------------------------------------------------------------------------------- /test/error/ConstArrayReadWrite.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | const int[]! c = { 5, 10 }; //ERROR: Invalid constant type 6 | return true; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/error/LexLiteralCharUnterminated.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int a = 'x; //ERROR: Unterminated character literal 6 | return true; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/error/LexLiteralDecOverflow2.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | long a = 9223372036854775808; //ERROR: Integer too big 6 | return true; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/error/MethodOverrideNotFound.fu: -------------------------------------------------------------------------------- 1 | abstract class Base 2 | { 3 | } 4 | 5 | class Derived : Base 6 | { 7 | public override void Foo() //ERROR: No method to override 8 | { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/error/OpEqualStringInt.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int i = 42; 6 | return "42" == i; //ERROR: Cannot compare 'string' with 'int' 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/error/StringInterpolatedArgError.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | string() s = $"|{foo}|"; //ERROR: 'foo' not found 6 | return true; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/error/TypeRangeMaxLimit.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | 0 .. 5000000000 i = 0; //ERROR: Only 32-bit ranges supported 6 | return true; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2022", 4 | "noEmit": true, 5 | "strictNullChecks": false, 6 | "forceConsistentCasingInFileNames": true 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/DoubleTryParse.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | double d; 6 | return !d.TryParse("foo") && d.TryParse("5") && d == 5; //FAIL: py swift cl 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/OpIndexArrayStg.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int[2] a; 6 | a[1] = 7; 7 | a[0] = 5; 8 | return a[0] == 5 && a[1] == 7; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/StReturnStringNull.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | static string? ReturnString() => null; 4 | 5 | public static bool Run() 6 | { 7 | return ReturnString() == null; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/StWhile.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int i = 0; 6 | int s = 0; 7 | while (i < 5) 8 | s += i++; 9 | return s == 10; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/error/FieldInitThrows.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | static int Foo() throws Exception => 42; 4 | 5 | int Bar = Foo(); //ERROR: Cannot call method 'Foo' here because it is marked 'throws' 6 | } 7 | -------------------------------------------------------------------------------- /test/error/LexLiteralFloatUnderscoreExp.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | double a = 1_e2; //ERROR: Invalid floating-point number 6 | return true; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/error/MainReturnFloat.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static float //ERROR: 'Main' method must return 'void' or 'int' 4 | Main() 5 | { 6 | return 0; 7 | } 8 | } 9 | 10 | -------------------------------------------------------------------------------- /test/error/OpIndexObject.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | public static bool Run() 4 | { 5 | Test() o; 6 | int i = o["foo"]; //ERROR: Cannot index this object 7 | return true; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/error/StForeachUndefined.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | public static bool Run() 4 | { 5 | foreach (int i in what) { //ERROR: 'what' not found 6 | } 7 | return true; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/error/TypeRangeMinLimit.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | -5000000000 .. 100 i = 0; //ERROR: Only 32-bit ranges supported 6 | return true; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/OpAddStringInterpolated.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | const int answer = 42; 6 | return "The answer " + $"is {answer}" == "The answer is 42"; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/OpDivDouble.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | double a = 7; //FAIL: cl if no double support 6 | double b = 2; 7 | return a / b == 3.5; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/OpNotEqualString2.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | string p = "bar"; 6 | string p2 = "foo"; 7 | return p != p2 8 | && p != "foo"; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/PreElseIf.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | #if true 6 | return true; 7 | #else 8 | #if true 9 | return false; 10 | #endif 11 | #endif 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/StForFloat.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | float s = 0; 6 | for (float f = 0.5; f < 5; f++) 7 | s += f; 8 | return s == 12.5; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/error/ConstNameNotId.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | const bool "wtf" = true; //ERROR: Expected identifier, got string constant 6 | return wtf; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/error/LexLiteralDecOverflow.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | long a = 123456789012345678901234567890; //ERROR: Integer too big 6 | return true; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/error/LexLiteralHexOverflow.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | long a = 0x123456789012345678901234567890; //ERROR: Integer too big 6 | return true; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/error/LexResourceSyntax3.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | byte[] a = resource("foo"); //ERROR: Expected 'resource' 6 | return true; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/error/OpAssignLiteral.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | 2 = 4; //ERROR: Cannot modify this //ERROR: Cannot convert '4' to '2' 6 | return true; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/error/OpSelectTypeMismatch.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | public static bool Run() 4 | { 5 | string s = true ? "five" : 5; //ERROR: Incompatible types: 'string' and '5' 6 | return true; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/error/PreElseUnterminated.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | #if true 6 | return true; 7 | } 8 | } 9 | #else 10 | //ERROR: Expected '#endif', got end-of-file -------------------------------------------------------------------------------- /test/error/ResourceNameInt.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | byte[] a = resource(42); //ERROR: Resource name must be a string 6 | return true; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/error/TypeStringSize.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | string(5) s = "foo"; //ERROR: Expected empty parentheses for storage type 6 | return true; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/ConstInt.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public const int Foo = 42; 4 | 5 | const int Bar = -5; 6 | 7 | public static bool Run() 8 | { 9 | return Foo == 42 && Bar == -5; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/PreEqual.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | #if true == false 6 | return false; 7 | #endif 8 | #if true == true 9 | return true; 10 | #endif 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/StackOfPtr.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | public static bool Run() 4 | { 5 | Stack() s; //FAIL: cl 6 | Test() o; 7 | s.Push(o); 8 | return s.Count == 1 && s.Pop() == o; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/StringReplace.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | public static bool Run() 4 | { 5 | string s = "foobar"; 6 | string() r = s.Replace("o", "uu"); //FAIL: cl 7 | return r == "fuuuubar"; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/error/LexLiteralFloatFractUnderscoreExp.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | double a = 1.0_e2; //ERROR: Invalid floating-point number 6 | return true; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/error/LexLiteralStringEndOfLine.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | string s = "//ERROR: Unterminated string literal 6 | ; 7 | return true; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/error/OpEqualStringStgNull.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | string() s = "foo"; 6 | return s == null; //ERROR: Cannot compare 'string()' with 'null' 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/error/OpIndexStringBounds.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | string s = "foo"; 6 | int i = s[-2]; //ERROR: Negative index 7 | return true; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/error/OpPostDecRightCondOr.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int i = 0; 6 | return i == 5 || i-- == 0; //ERROR: -- not allowed on the right side of || 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/error/OpPreIncRightCondAnd.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int i = 0; 6 | return i == 0 && ++i == 1; //ERROR: ++ not allowed on the right side of && 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/error/PreElseElse.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | #if false 6 | #else 7 | return true; 8 | #else //ERROR: '#else' after '#else' 9 | #endif 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/error/PreElseElse2.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | #if true 6 | return true; 7 | #else 8 | #else //ERROR: '#else' after '#else' 9 | #endif 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/error/UnreachableWhile.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | while (true) { 6 | } 7 | while (false) { //ERROR: Unreachable statement 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/LexLiteralCharUnicode.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int ci = 'Ć'; 6 | int beer = '🍺'; 7 | return ci == 0x106 8 | && beer == 0x1f37a; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/MethodParamByte.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | static bool Is255(byte b) 4 | { 5 | return b == 255; 6 | } 7 | 8 | public static bool Run() 9 | { 10 | return Is255(255); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/OpPreIncWhile.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int s = 0; 6 | int i = 0; 7 | while (++i < 4) 8 | s += i; 9 | return i == 4 && s == 6; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/PreNotEqual.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | #if true != true 6 | return false; 7 | #endif 8 | #if true != false 9 | return true; 10 | #endif 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/StElse.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int a = 1; 6 | int b = 2; 7 | if (a == 5) 8 | b--; 9 | else 10 | b++; 11 | return b == 3; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/error/ConstArrayLengthMismatch.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | const int[3] c = { 5, 10 }; //ERROR: Declared 3 elements, initialized 2 6 | return true; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/error/ConstValueBase.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | const int Foo = base.Bar(); //ERROR: 'base' invalid outside methods 4 | 5 | public static bool Run() 6 | { 7 | return true; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/error/MainParams.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static void Main( //ERROR: 'Main' method must have no parameters or one 'string[]' parameter 4 | int argc, string[] argv) 5 | { 6 | } 7 | } 8 | 9 | -------------------------------------------------------------------------------- /test/error/MethodBaseNotFound.fu: -------------------------------------------------------------------------------- 1 | public class Base 2 | { 3 | } 4 | 5 | public class Test : Base 6 | { 7 | bool Foo() => base.Bar(); //ERROR: 'Bar' not found 8 | 9 | public static bool Run() => true; 10 | } 11 | -------------------------------------------------------------------------------- /test/error/OpAndAssignDouble.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | float f = 5; 6 | f &= 1; //ERROR: Cannot convert 'float' to 'int' 7 | return true; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/error/PreElseElif.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | #if false 6 | #else 7 | return true; 8 | #elif true //ERROR: '#elif' after '#else' 9 | #endif 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/error/PreElseElif2.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | #if true 6 | return true; 7 | #else 8 | #elif true //ERROR: '#elif' after '#else' 9 | #endif 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/error/SymbolDuplicate.fu: -------------------------------------------------------------------------------- 1 | public class Foo 2 | { 3 | public const int A = 0; 4 | public const int A = 0; //ERROR: Duplicate symbol 5 | } 6 | 7 | public class Foo //ERROR: Duplicate symbol 8 | { 9 | } 10 | -------------------------------------------------------------------------------- /test/OpIndexArrayPtr.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int[2] a; 6 | a[1] = 7; 7 | a[0] = 5; 8 | int[] b = a; 9 | return b[0] == 5 && b[1] == 7; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/StForeachString.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | public static bool Run() 4 | { 5 | int sum = 0; 6 | foreach (int c in "foo") 7 | sum += 1 + c; 8 | return sum == 3 + 'f' + 'o' + 'o'; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/error/ConstIntAggregateInitializer.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | const int c = { 5, 10 }; //ERROR: Array initializer for scalar constant 'c' 6 | return true; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/error/MethodCallTooManyArgs.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | static bool Foo() => true; 4 | 5 | public static bool Run() 6 | { 7 | return Foo(42); //ERROR: Too many arguments for 'Foo' 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/error/PreElseGarbage.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | #if false 6 | #else foo //ERROR: Unexpected characters after '#else' 7 | return true; 8 | #endif 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/error/StAssertMessageNotString.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | assert true, true; //ERROR: The second argument of 'assert' must be a string 6 | return true; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/error/StForeachClass.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | public static bool Run() 4 | { 5 | Test() o; 6 | foreach (int i in o) { //ERROR: 'foreach' invalid on 'Test' 7 | } 8 | return true; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/error/UnreachableDoWhile.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | do { 6 | } while (true); 7 | do { //ERROR: Unreachable statement 8 | } while (false); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/error/UnreachableFor.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | for (;;) { 6 | } 7 | for (int i = 0; i < 10; i++) { //ERROR: Unreachable statement 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/error/VarInitAssign.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int x = 1; 6 | int y = x += 4; //ERROR: Expected ';', got '+=' 7 | return x == 5 && y == 5; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "fut-js", 3 | "private": true, 4 | "version": "3.2.13-development", 5 | "repository": "https://github.com/fusionlanguage/fut.git", 6 | "author": "Piotr Fusik", 7 | "type": "module" 8 | } 9 | -------------------------------------------------------------------------------- /test/ClassForwardBase.fu: -------------------------------------------------------------------------------- 1 | public class Test : Base 2 | { 3 | public static bool Run() 4 | { 5 | Test() o; 6 | return o.Foo == 42; 7 | } 8 | } 9 | 10 | public class Base 11 | { 12 | protected int Foo = 42; 13 | } 14 | -------------------------------------------------------------------------------- /test/ConstString.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public const string Foo = "foo"; 4 | 5 | public static bool Run() 6 | { 7 | const string foo = "bar"; 8 | return Foo == "foo" && foo == "bar"; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/HashSetOfPtr.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | public static bool Run() 4 | { 5 | HashSet() s; //FAIL: swift TODO; cl 6 | Test() o; 7 | s.Add(o); 8 | return s.Count == 1 && s.Contains(o); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/OpPreDecDoWhile.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int s = 0; 6 | int i = 3; 7 | do 8 | s += i; 9 | while (--i > 1); 10 | return i == 1 && s == 5; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/PreStringInterpolated.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | #if false 6 | int a = 0; 7 | Console.WriteLine($"{a}"); 8 | #endif 9 | return true; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/error/ConstNonConst.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int x = 5; 6 | const int y = x; //ERROR: Value for constant 'y' is not constant 7 | return true; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/error/LexLiteralLeadingZero.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int a = 011; //ERROR: Leading zeros are not permitted, octal numbers must begin with 0o 6 | return true; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/error/MethodCallTooFewArgs.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | static bool Foo(int x) => x == 42; 4 | 5 | public static bool Run() 6 | { 7 | return Foo(); //ERROR: Too few arguments for 'Foo' 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/error/OpAddStringBool.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | bool b = true; 6 | string() s = "b=" + b; //ERROR: Cannot convert 'bool' to 'string' 7 | return b; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/error/OpAndFloat.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | float f = 5; 6 | return f & 1; //ERROR: Cannot convert 'float' to 'int' //ERROR: Cannot convert 'int' to 'bool' 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/error/PreEndifGarbage.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | #if false 6 | #else 7 | return true; 8 | #endif foo //ERROR: Unexpected characters after '#endif' 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/error/StForeachInt.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int n = 5; 6 | foreach (int i in n) { //ERROR: 'foreach' invalid on 'int' 7 | } 8 | return true; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/error/StNativeUnterminated.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | native { //ERROR: Expected '}', got end-of-file //ERROR: Expected '}', got end-of-file //ERROR: Expected '}', got end-of-file -------------------------------------------------------------------------------- /test/Lock.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | Lock() mutex; //FAIL: c TODO; js ts cl 6 | lock (mutex) { 7 | lock (mutex) { 8 | return true; 9 | } 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/MathE.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | double e = Math.E; //FAIL: cl if no double support 6 | return e > 2.7182817 && e < 2.7182819 7 | && Math.Log(e) == 1; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/OpPostIncDoWhile.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int s = 0; 6 | int i = 1; 7 | do 8 | s += i; 9 | while (i++ < 4); 10 | return i == 5 && s == 10; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/StElseIf.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int a = 1; 6 | int b = 2; 7 | if (a == 5) 8 | b--; 9 | else if (b == 2) 10 | b++; 11 | return b == 3; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/error/DynamicObjectLeakInit.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | public static bool Run() 4 | { 5 | Test p = new Test(); //ERROR: Dynamically allocated object must be assigned to a 'Test#' reference 6 | return true; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/error/StForUninitializedInit.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | for (int i; i < 10; ) { //ERROR: Uninitialized variable // TODO: with i++ 6 | } 7 | return true; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/EnumToInt.fu: -------------------------------------------------------------------------------- 1 | enum Number 2 | { 3 | One = 1, 4 | Five = 5 5 | } 6 | 7 | public static class Test 8 | { 9 | public static bool Run() 10 | { 11 | return Number.One.ToInt() == 1 && Number.Five.ToInt() == 5; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/FloatToInt.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int e = Math.Truncate(Math.E); 6 | float f = Math.PI; 7 | byte pi = Math.Floor(f); 8 | return e == 2 && pi == 3; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/ObjectFieldArrayStg.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | int[2] Foo; 4 | 5 | public static bool Run() 6 | { 7 | Test() o; 8 | o.Foo[0] = 5; 9 | o.Foo[1] = 10; 10 | return o.Foo[0] == 5 && o.Foo[1] == 10; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/RegexOptions.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | public static bool Run() 4 | { 5 | RegexOptions o = RegexOptions.IgnoreCase | RegexOptions.Multiline; //FAIL: swift TODO 6 | return o.HasFlag(RegexOptions.IgnoreCase); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/StBreakFor.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int s = 0; 6 | for (int i = 0;;) { 7 | if (s > 9) 8 | break; 9 | s += i++; 10 | } 11 | return s == 10; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/StringStg.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | string() Foo = "foo"; //FAIL: cl 4 | 5 | public static bool Run() 6 | { 7 | Test() o; 8 | string() foo = "bar"; 9 | return o.Foo == "foo" && foo == "bar"; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/error/OpEqualArrayStgInt.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int[2] a; 6 | a[0] = 5; 7 | a[1] = 5; 8 | return a == 5; //ERROR: Cannot compare 'int[2]' with '5' 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/ClassForwardStg.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | Data() Bar; 4 | 5 | public static bool Run() 6 | { 7 | Test() o; 8 | return o.Bar.Foo == 42; 9 | } 10 | } 11 | 12 | class Data 13 | { 14 | internal int Foo = 42; 15 | } 16 | -------------------------------------------------------------------------------- /test/MathCos.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | double a = 0; //FAIL: cl if no double support 6 | float f = 0; 7 | f = Math.Cos(f); 8 | return Math.Cos(a) == 1 && f == 1; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/MathLog.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | double a = 1; //FAIL: cl if no double support 6 | float f = 1; 7 | f = Math.Log(f); 8 | return Math.Log(a) == 0 && f == 0; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/MathSin.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | double a = 0; //FAIL: cl if no double support 6 | float f = 0; 7 | f = Math.Sin(f); 8 | return Math.Sin(a) == 0 && f == 0; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/MathTan.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | double a = 0; //FAIL: cl if no double support 6 | float f = 0; 7 | f = Math.Tan(f); 8 | return Math.Tan(a) == 0 && f == 0; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/ObjectConstructor.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | int Foo; 4 | 5 | Test() 6 | { 7 | Foo = 41; 8 | this.Foo++; 9 | } 10 | 11 | public static bool Run() 12 | { 13 | Test() o; 14 | return o.Foo == 42; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /test/OpEqualArrayPtr.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | const int[3] a = { 5, 10, 15 }; 6 | const int[3] b = { 5, 10, 15 }; 7 | int[] p = a; 8 | return p == a && !(p == b); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/error/ClassBaseCircular.fu: -------------------------------------------------------------------------------- 1 | public class Foo : Test //ERROR: Circular inheritance for class 'Foo' 2 | { 3 | } 4 | 5 | public class Test : Foo //ERROR: Circular inheritance for class 'Test' 6 | { 7 | public static bool Run() => true; 8 | } 9 | -------------------------------------------------------------------------------- /test/error/DynamicArrayLeakInit.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int[] p = new int[3]; //ERROR: Dynamically allocated array must be assigned to a 'int[]#' reference 6 | return true; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/error/LexLiteralBinOverflow.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | long a = 0b11111111111111111111111111111111111111111111111111111111111111111; //ERROR: Integer too big 6 | return true; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/error/OpAddAssignStringObjectStg.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | public static bool Run() 4 | { 5 | Test() o; 6 | string() s = "o="; 7 | s += o; //ERROR: Cannot convert 'Test()' to 'string' 8 | return true; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/error/OpAddVoid.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | static void Foo() 4 | { 5 | } 6 | 7 | public static bool Run() 8 | { 9 | int i = 5 + Foo(); //ERROR: Cannot convert 'void' to 'int' 10 | return true; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/error/OpAssignTrailingId.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int x; 6 | x = foo bar; //ERROR: Expected ';', got identifier //ERROR: Invalid expression 7 | return true; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /editors/vscode/fu-file.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /test/ArrayStgContains.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int[3] a; 6 | a[0] = 5; 7 | a[1] = 10; 8 | a[2] = 15; 9 | return a.Contains(10) && !a.Contains(1); //FAIL: java cl 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/MathAcos.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | double a = 1; //FAIL: cl if no double support 6 | float f = 1; 7 | f = Math.Acos(f); 8 | return Math.Acos(a) == 0 && f == 0; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/MathAsin.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | double a = 0; //FAIL: cl if no double support 6 | float f = 0; 7 | f = Math.Asin(f); 8 | return Math.Asin(a) == 0 && f == 0; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/MathAtan.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | double a = 0; //FAIL: cl if no double support 6 | float f = 0; 7 | f = Math.Atan(f); 8 | return Math.Atan(a) == 0 && f == 0; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/MathCosh.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | double a = 0; //FAIL: cl if no double support 6 | float f = 0; 7 | f = Math.Cosh(f); 8 | return Math.Cosh(a) == 1 && f == 1; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/MathLog2.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | double a = 8; //FAIL: cl if no double support 6 | float f = 8; 7 | f = Math.Log2(f); 8 | return Math.Log2(a) == 3 && f == 3; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/MathSinh.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | double a = 0; //FAIL: cl if no double support 6 | float f = 0; 7 | f = Math.Sinh(f); 8 | return Math.Sinh(a) == 0 && f == 0; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/MathSqrt.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | double a = 4; //FAIL: cl if no double support 6 | float f = 9; 7 | f = Math.Sqrt(f); 8 | return Math.Sqrt(a) == 2 && f == 3; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/MathTanh.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | double a = 0; //FAIL: cl if no double support 6 | float f = 0; 7 | f = Math.Tanh(f); 8 | return Math.Tanh(a) == 0 && f == 0; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/ObjectFieldProtected.fu: -------------------------------------------------------------------------------- 1 | public class Base 2 | { 3 | protected int Foo; 4 | } 5 | 6 | public class Test : Base 7 | { 8 | public static bool Run() 9 | { 10 | Test() o; 11 | o.Foo = 42; 12 | return o.Foo == 42; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test/OpField.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | int Foo; 4 | 5 | int GetFoo() => this.Foo; 6 | 7 | public static bool Run() 8 | { 9 | Test() t; 10 | t.Foo = 42; 11 | return t.Foo == 42 12 | && t.GetFoo() == 42; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test/OpNotEqualArrayPtr.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | const int[3] a = { 5, 10, 15 }; 6 | const int[3] b = { 5, 10, 15 }; 7 | int[] p = a; 8 | return !(p != a) && p != b; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/StringSubstringZero.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | string() s = "barek"; //FAIL: cl 6 | s = s.Substring(0, 3); 7 | return s == "bar" 8 | && s.Substring(0) == "bar"; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/error/ArrayReadOnlyPtrModify.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | public bool Run() 4 | { 5 | int[2] a; 6 | int[] p = a; 7 | p[1] = 4; //ERROR: Cannot modify collection through a read-only reference 8 | return true; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/error/ConsoleWriteObjectPtr.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | public static bool Run() 4 | { 5 | Test() o; 6 | Test p = o; 7 | Console.WriteLine(p); //ERROR: Cannot convert 'Test' to 'printable' 8 | return true; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/error/MainDuplicate.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static void Main() 4 | { 5 | } 6 | } 7 | 8 | public static class Foo 9 | { 10 | public static void Main() //ERROR: Duplicate 'Main' method 11 | { 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/error/MethodBaseNotMethod.fu: -------------------------------------------------------------------------------- 1 | public class Base 2 | { 3 | internal int Bar; 4 | } 5 | 6 | public class Test : Base 7 | { 8 | bool Foo() => base.Bar(); //ERROR: Expected a method 9 | 10 | public static bool Run() => true; 11 | } 12 | -------------------------------------------------------------------------------- /test/error/MethodParamNameNotId.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | static int Id(int "bar") => bar; //ERROR: Expected identifier, got string constant 4 | 5 | public static bool Run() 6 | { 7 | return Id(42) == 42; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/error/MethodPrivateOverride.fu: -------------------------------------------------------------------------------- 1 | abstract class Base 2 | { 3 | internal abstract void Foo(); 4 | } 5 | 6 | class Derived : Base 7 | { 8 | override //ERROR: Private method cannot be override 9 | void Foo() 10 | { 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/error/StSwitchValueNotFound.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | switch (x) { //ERROR: 'x' not found 6 | case 1: 7 | return false; 8 | default: 9 | return true; 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /debian/copyright: -------------------------------------------------------------------------------- 1 | Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ 2 | Name: fut 3 | Source: https://github.com/fusionlanguage/fut 4 | 5 | Files: * 6 | Copyright: 2011-2025 Piotr Fusik 7 | License: GPL-3+ 8 | -------------------------------------------------------------------------------- /test/ConsoleErrorWrite.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | Console.Error.Write("Hello"); //FAIL: swift TODO; cl 6 | int i = 42; 7 | Console.Error.Write($"i={i:X}"); 8 | return true; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/ConsoleErrorWriteCodePoint.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | Console.Error.WriteCodePoint('5'); //FAIL: c swift TODO; cl 6 | Console.Error.WriteCodePoint('🍺'); 7 | return true; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/DynamicReset.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | public static bool Run() 4 | { 5 | Test#? p = new Test(); //FAIL: cl 6 | p = null; 7 | 8 | int[]#? a = new int[2]; 9 | a = null; 10 | return p == null && a == null; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/MathLog10.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | double a = 100; //FAIL: cl if no double support 6 | float f = 100; 7 | f = Math.Log10(f); 8 | return Math.Log10(a) == 2 && f == 2; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/MethodParamAssign.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | static int Foo(int i) 4 | { 5 | i++; 6 | return i; 7 | } 8 | 9 | public static bool Run() 10 | { 11 | int i = 41; 12 | return Foo(i) == 42 && i == 41; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test/ObjectFieldInit.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | int Foo = 42; 4 | 5 | static int Init() => 5; 6 | 7 | int Bar = Init(); 8 | 9 | public static bool Run() 10 | { 11 | Test() o; 12 | return o.Foo == 42 && o.Bar == 5; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test/StBreakWhile.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int i = 0; 6 | int s = 0; 7 | while (i < 10) { 8 | if (s > 9) 9 | break; 10 | s += i++; 11 | } 12 | return s == 10; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test/StReturn.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int s = 0; 6 | for (int i = 0; i < 15; i++) { 7 | if (i == 5) 8 | return s == 10; 9 | s += i; 10 | } 11 | return false; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/error/MethodOverrideNormal.fu: -------------------------------------------------------------------------------- 1 | abstract class Base 2 | { 3 | public void Foo() 4 | { 5 | } 6 | } 7 | 8 | class Derived : Base 9 | { 10 | public override void Foo() //ERROR: Base method is not abstract or virtual 11 | { 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/error/MethodOverrideReturnTypeMismatch.fu: -------------------------------------------------------------------------------- 1 | abstract class Base 2 | { 3 | public virtual int Foo() => 5; 4 | } 5 | 6 | class Derived : Base 7 | { 8 | public override long Foo() => 42; //ERROR: Base method has a different return type 9 | } 10 | -------------------------------------------------------------------------------- /test/error/StForeachArrayStgTypeMismatch.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int[3] a; 6 | foreach (string s in a) { //ERROR: Cannot convert 'int' to 'string' 7 | } 8 | return true; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/error/StForeachStringInString.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | string s = "foo"; 6 | foreach (string c in s) { //ERROR: Expected 'int' iterator variable 7 | } 8 | return true; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/DynamicArrayStringStg.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | string()[]# a = new string()[2]; //FAIL: cl 6 | a[0] = "foo"; 7 | a[1] = "bar"; 8 | return a[0] == "foo" && a[1] == "bar"; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/EnumFromInt.fu: -------------------------------------------------------------------------------- 1 | enum Number 2 | { 3 | One = 1, 4 | Five = 5 5 | } 6 | 7 | public static class Test 8 | { 9 | public static bool Run() 10 | { 11 | return Number.FromInt(1) == Number.One && Number.FromInt(5) == Number.Five; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/ListLast.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | List() list; //FAIL: cl 6 | list.Add("foo"); 7 | list.Add("bar"); 8 | list.Add("quux"); 9 | return list.Last() == "quux"; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/cs.runtimeconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "runtimeOptions": { 3 | "tfm": "net6.0", 4 | "rollForward": "LatestMajor", 5 | "framework": { 6 | "name": "Microsoft.NETCore.App", 7 | "version": "6.0.0" 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/error/MethodShortReturn.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() return true; //ERROR: Expected '{', got 'return' //ERROR: Invalid expression //ERROR: Expected identifier, got 'return' //ERROR: Expected identifier, got ';' 4 | } 5 | -------------------------------------------------------------------------------- /test/error/OpIndexArrayBounds.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int[5] a; 6 | int i = a[-2]; //ERROR: Negative index 7 | int j = a[5]; //ERROR: Array index out of bounds 8 | return true; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/error/PreExprInvalid.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | #if 1 + 2 //ERROR: Invalid preprocessor expression //ERROR: Expected end-of-line, got integer constant 6 | #endif 7 | return true; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/error/StForeachArrayStgKeyValue.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int[3] a; 6 | foreach ((int i, int value) in a) { //ERROR: Expected one iterator variable 7 | } 8 | return true; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/ArrayLength.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | const int[] a = { 5, 10, 15 }; 6 | switch (3) { 7 | case a.Length: 8 | return a[1] == 10; 9 | default: 10 | return false; 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/DynamicArrayByte.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | byte[]# a = new byte[3]; //FAIL: cl 6 | a[0] = 5; 7 | a[1] = 10; 8 | a[2] = 15; 9 | return a[0] == 5 && a[1] == 10 && a[2] == 15; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/MathCbrt.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | double a = 8; //FAIL: cl if no double support 6 | float f = 8; 7 | f = Math.Cbrt(f); 8 | return Math.Cbrt(a) == 2 && f == 2; //FAIL: py 3.11 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/StForRangeStep.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int s = 0; 6 | for (int i = 0; i < 5; i += 2) 7 | s += i; 8 | for (int i = 5; i > 0; i -= 3) 9 | s += i; 10 | return s == 6 + 7; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/error/DictionaryAddNotStg.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | Dictionary() dict; 6 | dict.Add(5); //ERROR: Method restricted to dictionaries with storage values 7 | return true; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/error/DynamicObjectLeakReturn.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | static Test Create() => new Test(); //ERROR: Dynamically allocated object must be assigned to a 'Test#' reference 4 | 5 | public static bool Run() 6 | { 7 | return true; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/error/ListStringSort.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | List() list; 6 | list.Add("foo"); 7 | list.Sort(); //ERROR: Method restricted to collections of numbers 8 | return true; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/error/ObjectStgBang.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | public static bool Run() 4 | { 5 | Test()! o; //ERROR: Unexpected '!' on a non-reference type 6 | int[5]! a; //ERROR: Unexpected '!' on a non-reference type 7 | return true; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/error/OpIncDecCondExp.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int i = 0; 6 | return i == 5 ? i++ == 0 : --i < 0; //ERROR: ++ not allowed on the right side of ? //ERROR: -- not allowed on the right side of ? 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/error/PreIfUnterminated2.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | #if false 6 | return true; 7 | } 8 | } //ERROR: Expected '#endif', got end-of-file //ERROR: Expected '}', got end-of-file //ERROR: Expected '}', got end-of-file -------------------------------------------------------------------------------- /test/error/StThrowNoThrows.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | static void Foo() 4 | { 5 | throw Exception("foo"); //ERROR: Method must be marked 'throws Exception' 6 | } 7 | 8 | public static bool Run() 9 | { 10 | return true; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/LexLiteralString.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | string s = "\"\n\r\t"; 6 | return s.Length == 4 7 | && s[0] == '\"' 8 | && s[1] == '\n' 9 | && s[2] == '\r' 10 | && s[3] == '\t'; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/MathTruncate.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | double a = 1.75; //FAIL: cl if no double support 6 | double b = -3.25; 7 | return Math.Truncate(a) == 1 && Math.Truncate(b) == -3; //FAIL: java 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/MethodThis.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | int Foo; 4 | 5 | int GetFoo() => this.Foo; 6 | 7 | int GetBar() => this.GetFoo(); 8 | 9 | public static bool Run() 10 | { 11 | Test() t; 12 | t.Foo = 42; 13 | return t.GetBar() == 42; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/ObjectInit.fu: -------------------------------------------------------------------------------- 1 | public class Point 2 | { 3 | internal int X; 4 | internal int Y; 5 | } 6 | 7 | public class Test 8 | { 9 | public static bool Run() 10 | { 11 | Point() bar = { X = 3, Y = 6 }; 12 | return bar.X == 3 && bar.Y == 6; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test/OpEqualNum.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int a = 42; 6 | int b = 42; 7 | double c = -5.25; //FAIL: cl if no double support 8 | double d = -5.25; 9 | return a == b 10 | && c == d; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/StReturnDestruct.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | static bool Foo() 4 | { 5 | string() s = "bar"; //FAIL: cl 6 | bool ok = s.Length == 3; 7 | return ok; 8 | } 9 | 10 | public static bool Run() 11 | { 12 | return Foo(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test/error/AssignForeachVar.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int[2] a; 6 | foreach (int i in a) { 7 | i = 1; //ERROR: Cannot assign a foreach iteration variable 8 | } 9 | return true; 10 | } 11 | } 12 | 13 | -------------------------------------------------------------------------------- /test/error/ObjectStgCopy.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | public static bool Run() 4 | { 5 | Test() o; 6 | Test() c = o; //ERROR: Cannot copy object storage 7 | Test() t; 8 | t = o; //ERROR: Cannot copy object storage 9 | return true; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/error/StSwitchCaseEndOfFile.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int x = 42; 6 | switch (x) { 7 | case 5: //ERROR: Expected '}', got end-of-file //ERROR: Expected '}', got end-of-file //ERROR: Expected '}', got end-of-file -------------------------------------------------------------------------------- /test/error/VisibilityPrivateConst.fu: -------------------------------------------------------------------------------- 1 | static class Foo 2 | { 3 | const int Bar = 42; 4 | } 5 | 6 | public static class Test 7 | { 8 | public static bool Run() 9 | { 10 | return Foo.Bar == 42; //ERROR: Cannot access private member 'Bar' 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/ListListPtr.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | List()>() lol; //FAIL: swift TODO; cl 6 | List()>! plol = lol; 7 | plol.Add(); 8 | lol[0].Add(42); 9 | return plol[0][0] == 42; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/OpAddNum.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int a = 1; 6 | int b = 2; 7 | double c = -0.5; //FAIL: cl if no double support 8 | double d = 3.75; 9 | return a + b == 3 10 | && c + d == 3.25; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/OpIndexString.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | string() s = "foo"; //FAIL: cl 6 | string p = "ba'r"; 7 | return s[1] == 'o' && p[1] == 'a' && p[2] == '\'' && "quux"[3] == 'x' && "\n"[0] == '\n'; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/OpSub.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int a = 42; 6 | int b = 2; 7 | double c = -0.5; //FAIL: cl if no double support 8 | double d = 3.75; 9 | return a - b == 40 10 | && c - d == -4.25; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/Range.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | 0 .. 9 DigitField = 3; 4 | const 0 .. 9 DigitConst = 7; 5 | 6 | public static bool Run() 7 | { 8 | 0 .. 9 digit = 5; 9 | Test() o; 10 | return digit == 5 && o.DigitField == 3 && DigitConst == 7; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/StReturnConstructor.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | int Foo; 4 | 5 | Test() 6 | { 7 | const int[] a = { 42 }; 8 | Foo = a[0]; 9 | return; 10 | } 11 | 12 | public static bool Run() 13 | { 14 | Test() o; 15 | return o.Foo == 42; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /test/StringStgInitPtr.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | static bool IsFoobar(string() s) => s == "foobar"; //FAIL: cl 4 | 5 | public static bool Run() 6 | { 7 | string p = "foobar"; 8 | string() s = p; 9 | return s == "foobar" && IsFoobar(p); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/error/ConstCircular.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | const int X = Y; //ERROR: Circular dependency in value of constant 'X' 4 | // FIXME: 5 | const int Y = X; //ERROR: Value for constant 'Y' is not constant //ERROR: Value for constant 'X' is not constant 6 | } 7 | -------------------------------------------------------------------------------- /test/error/DynamicArrayLeakReturn.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | static int[] Create() => new int[4]; //ERROR: Dynamically allocated array must be assigned to a 'int[]#' reference 4 | 5 | public static bool Run() 6 | { 7 | return true; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/error/LexLiteralFloatTrailingLetters.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | float f = 0.0f; //ERROR: Invalid floating-point number //ERROR: Expected ';', got identifier //ERROR: Invalid expression 6 | return true; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/error/MethodBaseStatic.fu: -------------------------------------------------------------------------------- 1 | public abstract class Base 2 | { 3 | protected bool Foo() => true; 4 | } 5 | 6 | public class Test : Base 7 | { 8 | public static bool Run() 9 | { 10 | return base.Foo(); //ERROR: 'base' invalid in static context 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/error/OpIsBase.fu: -------------------------------------------------------------------------------- 1 | public class Base 2 | { 3 | } 4 | 5 | public class Test : Base 6 | { 7 | public static bool Run() 8 | { 9 | Test() o; 10 | Test p = o; 11 | return p is Base; //ERROR: 'p' is 'Test', 'is Base' would always equal 'true' 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/error/StThrowNonString.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | static void Foo() throws Exception 4 | { 5 | throw Exception(42); //ERROR: Exception accepts a string argument 6 | } 7 | 8 | public static bool Run() 9 | { 10 | return true; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/error/VisibilityPrivateFieldStorage.fu: -------------------------------------------------------------------------------- 1 | class Foo 2 | { 3 | bool Priv = true; 4 | } 5 | 6 | public static class Test 7 | { 8 | public static bool Run() 9 | { 10 | Foo() o; 11 | return o.Priv; //ERROR: Cannot access private member 'Priv' 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/ConstByteArray.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public const byte[3] Foo = { 5, 10, 200 }; 4 | 5 | public static bool Run() 6 | { 7 | int sum = 0; 8 | for (int i = 0; i < Foo.Length; i++) 9 | sum += Foo[i]; 10 | return sum == 215; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/Double.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | double d = Math.PI; //FAIL: cl if no double support 6 | float f = d; 7 | double[2] a; 8 | a[0] = 1e200; 9 | return f > 3.14 && f < 3.15 && a[0] == 1e200; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/MathRound.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int i = Math.Round(200.75); 6 | return i == 201 && Math.Round(0.25) == 0 && Math.Round(1.75) == 2 7 | && Math.Round(Math.Pow(2.0, 100)) == Math.Pow(2.0, 100); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/OpEqualNull.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | public static bool Run() 4 | { 5 | Test? o = null; 6 | int[]? a = null; 7 | string? s = null; 8 | return o == null && null == o 9 | && a == null && null == a 10 | && s == null && null == s; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/OpGreater.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int a = 1; 6 | int b = 2; 7 | double c = 3; //FAIL: cl if no double support 8 | double d = 3.5; 9 | return !(a > b) 10 | && !(c > d) 11 | && d > b; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/RegexEscape.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | public static bool Run() 4 | { 5 | string() pattern = Regex.Escape("b+c"); //FAIL: cpp swift TODO; cl 6 | return Regex.IsMatch("a+b+c", Regex.Escape("b+c")) 7 | && Regex.IsMatch("a+b+c", pattern); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/StElseMethodStatic.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | static void Foo() 4 | { 5 | } 6 | 7 | public static bool Run() 8 | { 9 | int a = 1; 10 | int b = 2; 11 | if (a == 5) 12 | b--; 13 | else 14 | Foo(); 15 | return b == 2; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /test/StNativeInclude.fu: -------------------------------------------------------------------------------- 1 | #if C 2 | native { 3 | #include 4 | } 5 | #endif 6 | 7 | public static class Test 8 | { 9 | public static bool Run() 10 | { 11 | #if C 12 | native { 13 | puts("Hello"); 14 | } 15 | #endif 16 | return true; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /test/StSwitchArrayElement.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int[2] a; 6 | a[0] = 5; 7 | a[1] = 10; 8 | switch (a[1]) { 9 | case 10: 10 | return true; 11 | default: 12 | return false; 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/StringToLowerUpperMaxMin.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | public static bool Run() 4 | { 5 | string s = "Foo"; 6 | return Math.Min(5, 10) == 5 && Math.Max(5, 10) == 10 //FAIL: c 7 | && s.ToLower() == "foo" && s.ToUpper() == "FOO"; //FAIL: cl 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/error/ConsoleWriteLineArrayStg.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int[2] a; 6 | a[0] = 5; 7 | a[1] = 10; 8 | Console.WriteLine(a); //ERROR: Cannot convert 'int[2]' to 'printable' 9 | return true; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/error/OpIsReadOnlyReadWrite.fu: -------------------------------------------------------------------------------- 1 | public class Base 2 | { 3 | } 4 | 5 | public class Test : Base 6 | { 7 | public static bool Run() 8 | { 9 | Test() o; 10 | Base p = o; 11 | return p is Test! rw; //ERROR: 'Base' cannot be casted to 'Test!' 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/error/OpOrEnumNoFlags.fu: -------------------------------------------------------------------------------- 1 | enum Foo 2 | { 3 | Bar, 4 | Quux 5 | } 6 | 7 | public static class Test 8 | { 9 | public static bool Run() 10 | { 11 | Foo e = Foo.Bar | Foo.Quux; //ERROR: Define flags enumeration as 'enum* Foo' 12 | return true; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test/error/StSwitchCaseNotConst.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int x = 42; 6 | switch (x) { 7 | case x: //ERROR: Expected constant value 8 | return false; 9 | default: 10 | return false; 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/error/TypeNotFound.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | public static bool Run() 4 | { 5 | int i = 42; 6 | Foo foo; //ERROR: Type 'Foo' not found 7 | i j; //ERROR: Type 'i' not found 8 | Foo() o; //ERROR: Class 'Foo' not found 9 | return true; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/error/UnreachableIf.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | if (true) 6 | return true; 7 | else 8 | return false; 9 | if (true) //ERROR: Unreachable statement 10 | return false; 11 | return false; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/error/VisibilityPrivateMethodDerived.fu: -------------------------------------------------------------------------------- 1 | public class Base 2 | { 3 | static bool Priv() => true; 4 | } 5 | 6 | public class Test : Base 7 | { 8 | public static bool Run() 9 | { 10 | return Priv(); //ERROR: Cannot access private member 'Priv' 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/MathIsNaN.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | float zero = 0.0; 6 | float f = zero / zero; //FAIL: py 7 | double d = zero / zero; //FAIL: cl if no double support 8 | return Math.IsNaN(f) && Math.IsNaN(d); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/MethodCallFromConstructor.fu: -------------------------------------------------------------------------------- 1 | class Foo 2 | { 3 | static void Bar() 4 | { 5 | } 6 | 7 | internal Foo() 8 | { 9 | Bar(); 10 | } 11 | } 12 | 13 | public class Test 14 | { 15 | public static bool Run() 16 | { 17 | Foo() o; 18 | return true; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /test/MethodProtected.fu: -------------------------------------------------------------------------------- 1 | public class Base 2 | { 3 | protected bool Foo() => true; 4 | } 5 | 6 | public class Test : Base 7 | { 8 | bool Quux() => Foo(); 9 | 10 | public static bool Run() 11 | { 12 | Test() o; 13 | return o.Foo() 14 | && o.Quux(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /test/OpNeg.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int a = 42; 6 | byte b = 5; 7 | double c = 10.5; //FAIL: cl if no double support 8 | return -a == -42 9 | && -b == -5 //FAIL: swift TODO 10 | && -c == -10.5; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/OpPostInc.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int a = 42; 6 | int b = a++; 7 | byte[2] ba; 8 | ba[0] = 200; 9 | if (ba[0]++ != 200) 10 | return false; 11 | return a == 43 && b == 42 && ba[0] == 201; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/StSwitch.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int a = 42; 6 | switch (a) { 7 | case 4: 8 | case 7: 9 | return false; 10 | case 40 + 2: 11 | return true; 12 | default: 13 | return false; 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /test/StSwitchByte.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | byte[2] a; 6 | a[0] = 'N'; 7 | a[1] = 'G' + 128; 8 | switch (a[1]) { 9 | case 'G' + 128: 10 | return true; 11 | default: 12 | return false; 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/error/DynamicObjectInitLeakInit.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | internal int X; 4 | 5 | public static bool Run() 6 | { 7 | Test p = new Test { X = 5 }; //ERROR: Dynamically allocated object must be assigned to a 'Test#' reference 8 | return true; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/error/VarUninitialized.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int x; //ERROR: Uninitialized variable 6 | Dictionary dict; //ERROR: Uninitialized variable 7 | return x == 5 && dict.ContainsKey("foo"); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "fut-test-ts", 3 | "private": true, 4 | "version": "3.2.13-development", 5 | "repository": "https://github.com/fusionlanguage/fut.git", 6 | "author": "Piotr Fusik", 7 | "dependencies": { 8 | "ts-node": "^10.9.1" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/MathPow.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | double x = 2; //FAIL: cl if no double support 6 | double y = 3; 7 | float f = 2; 8 | float g = 3; 9 | f = Math.Pow(f, g); 10 | return Math.Pow(x, y) == 8 && f == 8; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/MethodArgTempDynamic.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | public static Test# Create() => new Test(); //FAIL: cl 4 | 5 | public static void Consume(Test t) 6 | { 7 | } 8 | 9 | public static bool Run() 10 | { 11 | Consume(Create()); 12 | return true; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test/MethodVoid.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | bool Result; 4 | 5 | void SideEffect!() 6 | { 7 | this.Result = true; 8 | } 9 | 10 | public static bool Run() 11 | { 12 | Test() o; 13 | o.Result = false; 14 | o.SideEffect(); 15 | return o.Result; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /test/OpPreDec.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int a = 42; 6 | int b = --a; 7 | byte[1] ba; 8 | ba[0] = 200; 9 | int c = 1 + --ba[0]; 10 | --ba[0]; 11 | return a == 41 && b == 41 && c == 200 && ba[0] == 198; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/error/MethodCallMutatingOnReadOnlyPtr.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | bool Foo!() => true; 4 | 5 | public static bool Run() 6 | { 7 | Test() o; 8 | Test r = o; 9 | return r.Foo(); //ERROR: Cannot call mutating method 'Foo' on a read-only reference 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/error/StSwitchCaseType.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int x = 42; 6 | switch (x) { 7 | case 1.5: //ERROR: Cannot convert 'double' to 'int' 8 | return false; 9 | default: 10 | return false; 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/error/VisibilityPrivateFieldDerivedStorage.fu: -------------------------------------------------------------------------------- 1 | public class Base 2 | { 3 | bool Priv = true; 4 | } 5 | 6 | public class Test : Base 7 | { 8 | public static bool Run() 9 | { 10 | Test() o; 11 | return o.Priv; //ERROR: Cannot access private member 'Priv' 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/error/VisibilityPrivateFieldPtr.fu: -------------------------------------------------------------------------------- 1 | class Foo 2 | { 3 | bool Priv = true; 4 | } 5 | 6 | public static class Test 7 | { 8 | public static bool Run() 9 | { 10 | Foo() o; 11 | Foo p = o; 12 | return p.Priv; //ERROR: Cannot access private member 'Priv' 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test/error/ConstNonConstEnum.fu: -------------------------------------------------------------------------------- 1 | enum Foo 2 | { 3 | Bar, 4 | Quux 5 | } 6 | 7 | public static class Test 8 | { 9 | public static bool Run() 10 | { 11 | Foo x = Foo.Bar; 12 | const Foo y = x; //ERROR: Value for constant 'y' is not constant 13 | return true; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/error/DynamicObjectLeakArgument.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | static void Foo(Test t) 4 | { 5 | } 6 | 7 | public static bool Run() 8 | { 9 | Foo(new Test()); //ERROR: Dynamically allocated object must be assigned to a 'Test#' reference 10 | return true; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/error/MethodOverrideParameterTypeMismatch.fu: -------------------------------------------------------------------------------- 1 | abstract class Base 2 | { 3 | public virtual void Foo(int x) 4 | { 5 | } 6 | } 7 | 8 | class Derived : Base 9 | { 10 | public override void Foo(long x) //ERROR: Base method has a different parameter type 11 | { 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/error/OpNewInt.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | public static bool Run() 4 | { 5 | return new int //ERROR: Invalid argument to new 6 | && new int { Value = 5 } //ERROR: Invalid argument to new 7 | && new Test! { Value = 5 }; //ERROR: Invalid argument to new 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/error/VisibilityPrivateMethodDerivedPtr.fu: -------------------------------------------------------------------------------- 1 | public class Base 2 | { 3 | bool Priv() => true; 4 | } 5 | 6 | public class Test : Base 7 | { 8 | public static bool Run() 9 | { 10 | Base() o; 11 | return o.Priv(); //ERROR: Cannot access private member 'Priv' 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | %: 3 | dh $@ 4 | 5 | override_dh_auto_build: 6 | dh_auto_build -- CXX=g++-13 CXXFLAGS="$(CXXFLAGS) -static-libstdc++" 7 | 8 | override_dh_auto_test: 9 | 10 | override_dh_auto_install: 11 | $(MAKE) DESTDIR=$$(pwd)/debian/tmp prefix=/usr install 12 | -------------------------------------------------------------------------------- /editors/vscode/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "files": [ 3 | "src/extension.ts", 4 | "src/fucheck.js" 5 | ], 6 | "compilerOptions": { 7 | "target": "es2021", 8 | "module": "commonjs", 9 | "allowJs": true, 10 | "strict": true, 11 | "outDir": "out" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/ArrayInt.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | 0 .. 200000[3] a; 6 | a[1] = 100_000; 7 | a[2] = a[1]; 8 | int[2] b; 9 | b[0] = 1; 10 | int c = a[b[0]++]; 11 | return a[1] == 100_000 && a[2] == 100_000 && c == 100_000; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/EncodingGetByteCount.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | string s = "quux"; 6 | return Encoding.UTF8.GetByteCount("foo") == 3 7 | && Encoding.UTF8.GetByteCount("bar") * 2 == 6 8 | && Encoding.UTF8.GetByteCount(s) == 4; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/LongTryParse.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | long l; 6 | return !l.TryParse("foo") && l.TryParse("42") && l == 42 //FAIL: java py swift cl 7 | && l.TryParse("123456789abcdef", 16) && l == 0x123456789abcdef; //FAIL: js ts 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/MathAtan2.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | double y = 0; //FAIL: cl if no double support 6 | double x = 1; 7 | float f = 0; 8 | float g = 1; 9 | f = Math.Atan2(f, g); 10 | return Math.Atan2(y, x) == 0 && f == 0; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/OpPostIncIf.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int a = 0; 6 | int b = 10; 7 | if (a++ != b) { 8 | a++; 9 | } 10 | else { 11 | b = -1; 12 | } 13 | if (b++ == 10) 14 | a++; 15 | return a == 3 && b == 11; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /test/error/ArrayPtrNullable.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | public bool Run() 4 | { 5 | Test?[] a = null; //ERROR: Cannot convert 'null' to 'Test?[]' 6 | Test[2] as; 7 | Test[]!? a1 = as; 8 | a1[0] = null; //ERROR: Cannot convert 'null' to 'Test' 9 | return true; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/error/ReturnDanglingPtrToObjectStg.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | public static Test Bad() 4 | { 5 | Test() o; 6 | return o; //ERROR: Returning dangling reference to local storage 7 | } 8 | 9 | public static bool Run() 10 | { 11 | Bad(); 12 | return true; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test/error/StSwitchCaseNullWhenInvalid.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | public static bool Run() 4 | { 5 | Test() o; 6 | Test p = o; 7 | switch (p) { 8 | case null when wtf: //ERROR: 'wtf' not found 9 | return true; 10 | default: 11 | return false; 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test/error/StSwitchDefaultEndOfFile.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int x = 42; 6 | switch (x) { 7 | case 5: 8 | break; 9 | default: //ERROR: Expected '}', got end-of-file //ERROR: Expected '}', got end-of-file //ERROR: Expected '}', got end-of-file -------------------------------------------------------------------------------- /test/OpBitAssignByte.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | byte[3] a; 6 | int i = 2; 7 | a[0] = 1; 8 | a[1] = 1; 9 | a[2] = 1; 10 | a[0] &= i; 11 | a[1] |= i; 12 | a[2] ^= i; 13 | return a[0] == 0 && a[1] == 3 && a[2] == 3; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/StForeachHashSet.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | HashSet() s; //FAIL: cl 6 | s.Add(15); 7 | s.Add(5); 8 | s.Add(10); 9 | int sum = 0; 10 | foreach (int value in s) 11 | sum += value; 12 | return sum == 30; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test/error/DynamicArrayLeakArgument.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | static void Foo(int[] p) 4 | { 5 | } 6 | 7 | public static bool Run() 8 | { 9 | Foo(new int[2]); //ERROR: Dynamically allocated array must be assigned to a 'int[]#' reference 10 | return true; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/error/MethodCallMutatingFromNonMutating.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | bool Foo!() => true; 4 | 5 | bool Bar() => Foo(); //ERROR: Cannot call mutating method 'Foo' from a non-mutating method 6 | 7 | public static bool Run() 8 | { 9 | Test() o; 10 | return o.Bar(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/error/StForeachDictionaryNoKeyValue.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | Dictionary() dict; 6 | dict[3] = 15; 7 | foreach (int i in dict) { //ERROR: Expected '(TKey key, TValue value)' iterator 8 | } 9 | return true; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/error/VisibilityProtectedFieldBaseStorage.fu: -------------------------------------------------------------------------------- 1 | public class Base 2 | { 3 | protected bool Prot = true; 4 | } 5 | 6 | public class Test : Base 7 | { 8 | public static bool Run() 9 | { 10 | Base() o; 11 | return o.Prot; //ERROR: Cannot access protected member 'Prot' 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/DynamicDictionary.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | static Dictionary# GetMap() 4 | { 5 | Dictionary# map = new Dictionary(); //FAIL: cl 6 | return map; 7 | } 8 | 9 | public static bool Run() 10 | { 11 | return GetMap().Count == 0; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/LexLiteralDouble.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | return 1.235e2 == 123.5 6 | && 2e-6 == 0.000_002 7 | && 1e+2 == 100 //FAIL: swift TODO https://github.com/swiftlang/swift/issues/76416 8 | && 1e+20 == 100000000000000000000.0; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/ListOfPtr.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | int X; 4 | 5 | public static bool Run() 6 | { 7 | List() list; //FAIL: cl 8 | list.Add(new Test()); 9 | list[0].X = 5; 10 | list.Add(new Test()); 11 | list[1].X = 10; 12 | return list[0].X == 5 && list[1].X == 10; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test/Long.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | static int Foo(int i) 4 | { 5 | long l = i; 6 | return l; 7 | } 8 | 9 | public static bool Run() 10 | { 11 | long l = 42; 12 | int i = l; 13 | i += l; //FAIL: cs js ts TODO 14 | i <<= Foo(1); 15 | return i == 168; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /test/OpEqualBool.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | bool t1 = true; 6 | bool t2 = true == true; 7 | bool f1 = false; 8 | bool f2 = false == true; 9 | return t1 == t2 && f1 == f2 && !(t1 == f2) && true == t1 && false == f2; //FAIL: ts 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/OpIsDynamic.fu: -------------------------------------------------------------------------------- 1 | class Base 2 | { 3 | protected virtual void Foo() { } 4 | } 5 | 6 | class Derived : Base 7 | { 8 | } 9 | 10 | public static class Test 11 | { 12 | public static bool Run() 13 | { 14 | Base# p = new Derived(); 15 | return p is Derived; //FAIL: c TODO; cl 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /test/error/LexResourceSyntax2.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | byte[] a = resource("foo"); //ERROR: Expected 'resource' //ERROR: Expected ';', got identifier //ERROR: Invalid expression //ERROR: Expected ';', got '>' 6 | return true; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/error/ListTwoTypeArgs.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | List() l; //ERROR: Expected 1 type arguments for 'List', got 2 6 | List? p = null; //ERROR: Expected 1 type arguments for 'List', got 2 7 | return true; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/error/ReturnDanglingPtrToArrayStg.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static int[] Bad() 4 | { 5 | int[2] a; 6 | return a; //ERROR: Returning dangling reference to local storage 7 | } 8 | 9 | public static bool Run() 10 | { 11 | Bad(); 12 | return true; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test/error/StSwitchCaseDefault.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int x = 42; 6 | switch (x) { 7 | case 42: 8 | return true; 9 | case 5: 10 | default: //ERROR: Please remove 'case' before 'default' 11 | return false; 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test/ClassForwardPtr.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | static bool DoWork(Data data) 4 | { 5 | return data.Foo == 42; 6 | } 7 | 8 | public static bool Run() 9 | { 10 | Data() data; 11 | return DoWork(data); 12 | } 13 | } 14 | 15 | class Data 16 | { 17 | internal int Foo = 42; 18 | } 19 | -------------------------------------------------------------------------------- /test/ObjectDestructorBase.fu: -------------------------------------------------------------------------------- 1 | public class Base 2 | { 3 | internal string() Foo; //FAIL: cl 4 | } 5 | 6 | public class Test : Base 7 | { 8 | public Test() 9 | { 10 | } 11 | 12 | public static bool Run() 13 | { 14 | Test() o; 15 | o.Foo = "bar"; 16 | return o.Foo == "bar"; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /test/OpAddAssignString.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | string() s = "foo"; //FAIL: cl 6 | string p = "bar"; 7 | string() s2 = "quux"; 8 | s2 += s; 9 | s2 += p; 10 | s2 += p + $"{p}" + s; 11 | return s2 == "quuxfoobar" + "barbarfoo"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/Resource.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | if (resource("lipsum.txt").Length != 26) 6 | return false; 7 | byte[] r = resource("lipsum.txt"); 8 | return Encoding.UTF8.GetString(r, 0, 26) == "Lorem ipsum dolor sit amet"; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/error/MethodCallError.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | static Test? Foo() 4 | { 5 | return null; // TODO: short method syntax constant-folds 6 | } 7 | 8 | public static bool Run() 9 | { 10 | return Foo() is Test; //ERROR: 'Foo' is 'Test', 'is Test' would always equal 'true' 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/error/OpIsUnrelated.fu: -------------------------------------------------------------------------------- 1 | public class Unrelated 2 | { 3 | } 4 | 5 | public class Test 6 | { 7 | public static bool Run() 8 | { 9 | Test() o; 10 | Test p = o; 11 | return p is Unrelated; //ERROR: 'Test' is not base class of 'Unrelated', 'is Unrelated' would always equal 'false' 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/error/StSwitchCaseFallthrough.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int x = 42; 6 | switch (x) { 7 | case 42: 8 | x++; //ERROR: 'case' must end with 'break', 'continue', 'return' or 'throw' 9 | default: 10 | return false; 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/error/SymbolGlobalInside.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | public static bool Run() 4 | { 5 | Test.Test.Test p; //ERROR: Invalid type 6 | Test.Test.Test() o; //ERROR: Invalid type 7 | long.int i; //ERROR: Invalid type 8 | return long.int.MaxValue > 0; //ERROR: 'int' not found 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/error/VisibilityPrivateFieldBase.fu: -------------------------------------------------------------------------------- 1 | public class Base 2 | { 3 | bool Priv = true; 4 | } 5 | 6 | public class Test : Base 7 | { 8 | bool Bar() => Priv; //ERROR: Cannot access private member 'Priv' 9 | 10 | public static bool Run() 11 | { 12 | Test() o; 13 | return o.Bar(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/summary.pl: -------------------------------------------------------------------------------- 1 | #!perl 2 | use strict; 3 | my %t; 4 | my %p; 5 | for (@ARGV) { 6 | m!/(\w+)\.txt$! or die; 7 | my $n = $1; 8 | $t{$n}++; 9 | open IN, $_ or die "$_: $!\n"; 10 | $p{$n} += =~ /^PASSED/; 11 | } 12 | print "PASSED"; 13 | print " $_=$p{$_}/$t{$_}" for sort keys %t; 14 | print "\n"; 15 | -------------------------------------------------------------------------------- /test/ConstFloat.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public const float Foo = -10.5; 4 | const float Two = 2; 5 | public const float[] Array = { -1.0, -2, 0.1 }; 6 | 7 | public static bool Run() 8 | { 9 | float f = Foo; 10 | return f == -10.5 && 1 / Two == 0.5 && Array[1] == -2; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/ObjectConstructorBase.fu: -------------------------------------------------------------------------------- 1 | public class Base 2 | { 3 | internal int Foo; 4 | 5 | Base() 6 | { 7 | Foo = 42; 8 | } 9 | } 10 | 11 | public class Test : Base 12 | { 13 | Test() 14 | { 15 | } 16 | 17 | public static bool Run() 18 | { 19 | Test() o; 20 | return o.Foo == 42; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /test/OpNotEqualNull.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | public static bool Run() 4 | { 5 | Test() o; 6 | Test? op = o; 7 | int[2] a; 8 | int[]? ap = a; 9 | string? sp = "foo"; 10 | return op != null && null != op 11 | && ap != null && null != ap 12 | && sp != null && null != sp; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test/StSwitchStringStg.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | string() s = "bar"; //FAIL: cl 6 | switch (s) { 7 | case "foo": 8 | case "quux": 9 | return false; 10 | case "bar": 11 | return true; 12 | default: 13 | return false; 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /test/error/ReturnDanglingPtrToStringStg.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static string Bad() 4 | { 5 | string() s = "foo"; 6 | return s; //ERROR: Returning dangling reference to local storage 7 | } 8 | 9 | public static bool Run() 10 | { 11 | Bad(); 12 | return true; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test/error/StForeachDictionaryKeyTypeMismatch.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | Dictionary() dict; 6 | dict[3] = 15; 7 | foreach ((string key, int value) in dict) { //ERROR: Cannot convert 'int' to 'string' 8 | } 9 | return true; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/error/StForeachDictionaryValueTypeMismatch.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | Dictionary() dict; 6 | dict[3] = 15; 7 | foreach ((int key, int value) in dict) { //ERROR: Cannot convert 'float' to 'int' 8 | } 9 | return true; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/error/SymbolUnknown.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | public static bool Run() 4 | { 5 | while (x) { //ERROR: 'x' not found 6 | } 7 | Foo.Bar; //ERROR: 'Foo' not found 8 | bool b = true; 9 | int y = b ? x : false; //ERROR: 'x' not found 10 | return x + 1; //ERROR: 'x' not found 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/error/VisibilityPrivateFieldDerivedPtr.fu: -------------------------------------------------------------------------------- 1 | public class Base 2 | { 3 | bool Priv = true; 4 | protected static bool Foo(Test t) => t.Priv; //ERROR: Cannot access private member 'Priv' 5 | } 6 | 7 | public class Test : Base 8 | { 9 | public static bool Run() 10 | { 11 | return true; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/ArrayStgContainsPtr.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | internal int X; 4 | 5 | public static bool Run() 6 | { 7 | Test?[2] a; 8 | Test() o = { X = 10 }; 9 | Test() o2 = { X = 20 }; 10 | a[0] = null; 11 | a[1] = o; 12 | return a.Contains(o) && !a.Contains(o2); //FAIL: java swift cl 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test/ConstLong.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public const long Foo = 1000000000000000; 4 | public const long Bar = 1000000000; 5 | 6 | public static bool Run() 7 | { 8 | int i = 1000000; 9 | return Foo == 1000000000000000 10 | && i * Bar == Foo; //FAIL: c cpp cs d java ts cl 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/OpLessOrEqual.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int a = 1; 6 | int b = 2; 7 | double c = 3; //FAIL: cl if no double support 8 | double d = 3.5; 9 | return a <= b && a + 1 <= b 10 | && c <= d && c + 0.5 <= d 11 | && b <= c && b + 1 <= c; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/OpPostIncReturn.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | const byte[] A = { 5, 10, 15 }; 4 | int Offset = 0; 5 | 6 | int Get!() => A[Offset++]; 7 | 8 | public static bool Run() 9 | { 10 | Test() o; 11 | int s = 0; 12 | for (int i = 0; i < 3; i++) 13 | s += o.Get(); 14 | return s == 30; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /test/StBlock.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int s = 0; 6 | { 7 | { 8 | { 9 | int i = 2; 10 | s += i; 11 | } 12 | { 13 | int i = 3; //FAIL: swift TODO 14 | s += i; 15 | } 16 | } 17 | return s == 5; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /test/error/VisibilityPrivateMethodBase.fu: -------------------------------------------------------------------------------- 1 | public class Base 2 | { 3 | bool Priv() => true; 4 | } 5 | 6 | public class Test : Base 7 | { 8 | bool Bar() => base.Priv(); //ERROR: Cannot access private member 'Priv' 9 | 10 | public static bool Run() 11 | { 12 | Test() o; 13 | return o.Bar(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/ObjectToString.fu: -------------------------------------------------------------------------------- 1 | public class Point 2 | { 3 | internal int X; 4 | internal int Y; 5 | public string() ToString() => $"{X},{Y}"; //FAIL: cl 6 | } 7 | 8 | public class Test 9 | { 10 | public static bool Run() 11 | { 12 | Point() bar = { X = 3, Y = 6 }; 13 | return bar.ToString() == "3,6"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/OpDivInt.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int a = 7; 6 | int b = 3; 7 | byte[2] ba; 8 | ba[0] = 7; 9 | ba[1] = 3; 10 | return a / b == 2 11 | && -7 / b == -2 12 | && 3 * (a / b) == 6 13 | && a / -3 == -2 14 | && ba[0] / ba[1] == 2; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /test/OpMod.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int a = 7; 6 | int b = 3; 7 | byte[2] ba; 8 | ba[0] = 7; 9 | ba[1] = 3; 10 | int c = 7; 11 | c %= 3; 12 | return a % b == 1 13 | && 3 * (a % b) == 3 14 | && ba[0] % ba[1] == 1 15 | && c == 1; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /test/error/StSwitchDefaultFallthrough.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int x = 42; 6 | switch (x) { 7 | case 5: 8 | break; 9 | default: 10 | x++; //ERROR: 'default' must end with 'break', 'continue', 'return' or 'throw' 11 | } 12 | return true; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test/error/VisibilityProtectedFieldNotDerived.fu: -------------------------------------------------------------------------------- 1 | public class Base 2 | { 3 | protected bool Prot = true; 4 | } 5 | 6 | public static class Test 7 | { 8 | static bool Foo(Base b) => b.Prot; //ERROR: Cannot access protected member 'Prot' 9 | 10 | public static bool Run() 11 | { 12 | return true; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test/EnumValue.fu: -------------------------------------------------------------------------------- 1 | enum Season 2 | { 3 | Spring = 1, 4 | Summer = 2, 5 | Autumn = 3, 6 | Winter = 4, 7 | Fall = 3, 8 | Last 9 | } 10 | 11 | public class Test 12 | { 13 | public static bool Run() 14 | { 15 | Season s = Season.Fall; 16 | return s == Season.Autumn && Season.Last == Season.Winter; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /test/MathExp.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | double a = 0; //FAIL: cl if no double support 6 | float f = 0; 7 | f = Math.Exp(f); 8 | return Math.Exp(a) == 1 && f == 1 9 | && (Math.Exp(1) > 2.7182817 || Math.Exp(1) < 2.7182819); //FAIL: d swift cl TODO 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/OpNotEqualNum.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int a = 42; 6 | int b = 5; 7 | double c = 3.25; //FAIL: cl if no double support 8 | double d = 3.5; 9 | byte[2] ba; 10 | ba[1] = 200; 11 | return a != b 12 | && c != d 13 | && !(ba[1] != 200); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/error/ClassStaticInstance.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | Test() o; //ERROR: Cannot instantiate static class 6 | Test()[3] a; //ERROR: Cannot instantiate static class 7 | Test# p = new Test(); //ERROR: Cannot instantiate static class 8 | return true; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/error/DynamicArrayLeakSelect.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int size = 5; 6 | int[10] FixedBuffer; 7 | int[] p = size <= 10 ? FixedBuffer : new int[size]; //ERROR: Dynamically allocated array must be assigned to a 'int[]#' reference 8 | return true; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/error/StSwitchFloat.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | float f = 2.5; 6 | switch (f) { //ERROR: 'switch' on type 'float' - expected 'int', 'enum', 'string' or object reference 7 | case 1.5: 8 | return false; 9 | default: 10 | return false; 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/error/StringInterpolatedArgUnknownMethod.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static string() GetMessage(string str) => $"First character: {CharToString(str[0])}"; //ERROR: 'CharToString' not found 4 | 5 | public static void Run() 6 | { 7 | Console.WriteLine(GetMessage("Hi")); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/ConsoleWrite.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | Console.Write("Hello"); 6 | int i = 42; 7 | Console.Write(i); 8 | float f = 10.5; 9 | Console.Write(f); 10 | Console.Write($"i={i:X} f={f:e}={f:F}={f}$"); //FAIL: cl if no double support 11 | return true; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/OpPostIncWhile.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int s = 0; 6 | int i = 0; 7 | while (i++ < 3) 8 | s += i; 9 | 10 | int j = 0; 11 | while (j++ < 3) { 12 | if (j == 2) 13 | break; 14 | s += j; 15 | } 16 | return i == 4 && j == 2 && s == 7; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /test/ArrayStgInit.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int[5] a = 0; 6 | byte[5] b = 0; 7 | bool[5] c = false; 8 | string?[5] s = null; 9 | for (int i = 0; i < 5; i++) 10 | if (a[i] != 0 || b[i] != 0 || c[i] || s[i] != null) 11 | return false; 12 | return true; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test/StBreakSwitch.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int s = 0; 6 | switch (s) { 7 | case 0: 8 | if (++s == 1) 9 | break; 10 | s = -10; 11 | break; 12 | case 1: 13 | s = -20; 14 | break; 15 | default: 16 | break; 17 | } 18 | return s == 1; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | [assembly: AssemblyProduct("Fusion Programming Language")] 5 | [assembly: AssemblyCopyright("Copyright © Piotr Fusik 2011-2025")] 6 | [assembly: ComVisible(false)] 7 | [assembly: AssemblyVersion("3.2.13.0")] 8 | [assembly: AssemblyFileVersion("3.2.13.0")] 9 | -------------------------------------------------------------------------------- /test/DictionaryDynamicList.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | Dictionary#>() dict; //FAIL: cl 6 | dict["foo"] = new List(); 7 | dict["foo"].Add(5); 8 | dict["foo"].Add(10); 9 | return dict.Count == 1 && dict["foo"][0] == 5 && dict["foo"][1] == 10; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/EnumLess.fu: -------------------------------------------------------------------------------- 1 | public enum DayOfWeek 2 | { 3 | Sunday, 4 | Monday, 5 | Tuesday, 6 | Wednesday, 7 | Thursday, 8 | Friday, 9 | Saturday 10 | } 11 | 12 | public class Test 13 | { 14 | public static bool Run() 15 | { 16 | DayOfWeek wed = DayOfWeek.Wednesday; 17 | return wed < DayOfWeek.Friday; //FAIL: py swift 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /test/MethodStatic.fu: -------------------------------------------------------------------------------- 1 | static class Util 2 | { 3 | public static bool Remote() 4 | { 5 | return true; 6 | } 7 | } 8 | 9 | public static class Test 10 | { 11 | static bool Local() 12 | { 13 | return true; 14 | } 15 | 16 | public static bool Run() 17 | { 18 | return Local() && Test.Local() && Util.Remote(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /test/ObjectFieldPublic.fu: -------------------------------------------------------------------------------- 1 | enum Season 2 | { 3 | Spring, 4 | Summer, 5 | Fall, 6 | Winter 7 | } 8 | 9 | public class Foo 10 | { 11 | public long Bar; 12 | Season Fav; 13 | } 14 | 15 | public static class Test 16 | { 17 | public static bool Run() 18 | { 19 | Foo() o; 20 | o.Bar = 42; 21 | return o.Bar == 42; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /test/ObjectPtrToStg.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | int Foo = 42; 4 | 5 | static bool Check(Test p) 6 | { 7 | return p.Foo == 42; 8 | } 9 | 10 | public static bool Run() 11 | { 12 | Test() o; 13 | Test p = o; 14 | Test p2; 15 | p2 = o; 16 | return p.Foo == 42 17 | && p2.Foo == 42 18 | && Check(o); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /test/StSwitchField.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | int Foo = 42; 4 | 5 | public static bool Run() 6 | { 7 | Test() o; 8 | switch (o.Foo) { 9 | case 4: 10 | case 7: 11 | int b = 5; 12 | return b != 5; 13 | case 40 + 2: 14 | return true; 15 | default: 16 | int c = 7; 17 | return c != 7; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /test/StackPtr.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | Stack() s; //FAIL: cl 6 | Stack! p = s; //FAIL: swift 7 | p.Push(42); 8 | p.Clear(); 9 | p.Push(5); 10 | s.Push(10); 11 | p.Push(15); 12 | p.Pop(); 13 | return p.Count == 2 && p.Pop() == 10 && p.Peek() == 5; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/LexLiteralChar.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int backslash = '\\'; 6 | return ' ' == 0x20 7 | && 'A' == 0x41 8 | && '\'' == 0x27 9 | && '"' == 0x22 10 | && '\\' == 0x5c && backslash == 0x5c 11 | && '\n' == 0x0a 12 | && '\r' == 0x0d 13 | && '\t' == 0x09; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/OpNot.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int i = 5; 6 | bool a = false; 7 | bool t = true; 8 | return !a 9 | && !(a && a) 10 | && !(a && !a) 11 | && !(a & a) 12 | && !(a & !a) 13 | && !(!t & a) 14 | && (!a | !a) 15 | && !(i == 0) 16 | && !(i != 5); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /test/StReturnObjectStg.fu: -------------------------------------------------------------------------------- 1 | class Data 2 | { 3 | internal int X; 4 | } 5 | 6 | public class Test 7 | { 8 | internal Data() ReturnStorage() 9 | { 10 | Data() d; 11 | d.X = 42; 12 | return d; 13 | } 14 | 15 | public static bool Run() 16 | { 17 | Test() o; 18 | Data() d = o.ReturnStorage(); 19 | return d.X == 42; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /test/TempNoBlock.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | byte[2] a; 6 | a[0] = 0x12; 7 | a[1] = 0x34; 8 | string() hex = ""; //FAIL: cl 9 | foreach (byte b in a) 10 | hex += $"{b:X2} "; 11 | foreach (byte b in a) 12 | hex += $"{b:X2} "; 13 | return hex == "12 34 12 34 "; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/error/LexLiteralFloatInvalid.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | double a = 1.2.3; //ERROR: Expected identifier, got integer constant 6 | double b = 1e2e3; //ERROR: Invalid floating-point number //ERROR: Expected ';', got identifier //ERROR: Invalid expression 7 | return true; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/error/MethodCallStaticWithInstance.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | const bool Foo = true; 4 | 5 | static void StaticMethod() 6 | { 7 | } 8 | 9 | public static bool Run() 10 | { 11 | Test() o; 12 | if (o.Foo) //ERROR: 'Foo' is static 13 | o.StaticMethod(); //ERROR: 'StaticMethod' is static 14 | return true; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /test/ArrayStgStringStg.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | string()[2] F; 4 | 5 | public static bool Run() 6 | { 7 | string()[2] a; //FAIL: cl 8 | a[0] = "foo"; 9 | a[1] = "bar"; 10 | Test() o; 11 | o.F[0] = "quux"; 12 | o.F[1] = "baz"; 13 | return a[0] == "foo" && a[1] == "bar" && o.F[0] == "quux" && o.F[1] == "baz"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/error/UnreachableSwitch.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | switch (42) { 6 | case 42: 7 | return true; 8 | default: 9 | return false; 10 | } 11 | switch (5) { //ERROR: Unreachable statement 12 | case 5: 13 | return false; 14 | default: 15 | return false; 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /test/ConsoleWriteLineSubstring.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | string s = "barek"; 6 | Console.WriteLine($"^{s.Substring(1, 3)}$"); 7 | const byte[4] b = { 'f', 'o', 'o', 'b' }; 8 | Console.WriteLine($"^{Encoding.UTF8.GetString(b, 1, 2), 3}$"); //FAIL: py swift TODO 9 | return true; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/StSwitchSubstring.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | string s = "foobar"; 6 | int len = 3; 7 | switch (s.Substring(1, len)) { 8 | case "": 9 | case "foobar": 10 | return false; 11 | case "ba": 12 | case "oob": 13 | return true; 14 | default: 15 | return false; 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /test/error/LexResourceSyntax1.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | byte[] a = resource("foo"); //ERROR: Expected 'resource' //ERROR: Expected a method //ERROR: Expected ';', got string constant //ERROR: Invalid expression //ERROR: Expected ';', got ')' //ERROR: Invalid expression 6 | return true; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/DictionaryList.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | Dictionary()>() dict; //FAIL: cl 6 | dict.Add("zamek"); 7 | dict["zamek"].Add("castle"); 8 | dict["zamek"].Add("lock"); 9 | 10 | return dict.Count == 1 && dict["zamek"][0] == "castle" && dict["zamek"][1] == "lock"; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/error/MethodCallNoThrows.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | static void Foo() 4 | { 5 | Bar(); //ERROR: Method marked 'throws Exception' called from a method without it 6 | } 7 | 8 | static void Bar() throws Exception 9 | { 10 | throw Exception("bar"); 11 | } 12 | 13 | public static bool Run() 14 | { 15 | return true; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /test/ExceptionSubclass.fu: -------------------------------------------------------------------------------- 1 | public class FooException : Exception 2 | { 3 | } 4 | 5 | public class BarException : FooException 6 | { 7 | } 8 | 9 | public static class Test 10 | { 11 | public static void Throw() throws FooException 12 | { 13 | throw BarException("foo"); 14 | } 15 | 16 | public static bool Run() 17 | { 18 | return true; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /test/IntTryParse.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int i; 6 | nint n; 7 | return !i.TryParse("foo") && !i.TryParse("2147483648") && i.TryParse("42") && i == 42 //FAIL: java js py swift ts cl 8 | && i.TryParse("c0d3", 16) && i == 0xc0d3 9 | && !n.TryParse("0x") && n.TryParse("1234") && n == 1234; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/MethodAbstract.fu: -------------------------------------------------------------------------------- 1 | abstract class Base 2 | { 3 | internal abstract bool Foo(); //FAIL: cl 4 | } 5 | 6 | class Derived : Base 7 | { 8 | internal override bool Foo() 9 | { 10 | return true; 11 | } 12 | } 13 | 14 | public static class Test 15 | { 16 | public static bool Run() 17 | { 18 | Base# d = new Derived(); 19 | return d.Foo(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /test/ObjectConstructorGrand.fu: -------------------------------------------------------------------------------- 1 | public class Base 2 | { 3 | internal int Foo; 4 | 5 | Base() 6 | { 7 | Foo = 42; 8 | } 9 | } 10 | 11 | public class Middle : Base 12 | { 13 | } 14 | 15 | public class Test : Middle 16 | { 17 | Test() 18 | { 19 | } 20 | 21 | public static bool Run() 22 | { 23 | Test() o; 24 | return o.Foo == 42; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /test/OpNotEqualString.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | string() s = "foo"; //FAIL: cl 6 | string() s2 = "bar"; 7 | string p = "bar"; 8 | string p2 = "foo"; 9 | return s != s2 10 | && s != p 11 | && p != s 12 | && p != p2 13 | && s != "bar" 14 | && p != "foo" 15 | && !(s != p2); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /test/OpPostIncFor.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int s = 0; 6 | int i = 0; 7 | int k; 8 | for (k = 0; i++ < 3; k++) 9 | s += i; 10 | 11 | int j = 0; 12 | for (; j++ < 3; k++) { 13 | if (j == 2) 14 | break; 15 | s += j; 16 | } 17 | return i == 4 && j == 2 && s == 7 && k == 4; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /test/OpPreIncIf.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int a = 0; 6 | int b = 1; 7 | if (++a == b) { 8 | a++; 9 | } 10 | else { 11 | b = -1; 12 | } 13 | if (++b == 2) 14 | a++; 15 | if (a == 42) { 16 | } 17 | else if (++a == 4) { 18 | b++; 19 | } 20 | return a == 4 && b == 3; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /test/PreDocApostrophe.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | #if false 6 | /// let's try this 7 | return false; 8 | #endif 9 | #if true 10 | return true; 11 | #elif true 12 | /// don't do this 13 | #else 14 | /// don't do this 15 | #endif 16 | #if true 17 | #else 18 | /// don't do this 19 | #endif 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /test/QueuePtr.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | Queue() q; //FAIL: cl 6 | Queue! p = q; //FAIL: swift 7 | p.Enqueue(42); 8 | p.Clear(); 9 | q.Enqueue(5); 10 | p.Enqueue(10); 11 | p.Enqueue(15); 12 | p.Dequeue(); 13 | return p.Count == 2 && p.Dequeue() == 10 && p.Peek() == 15; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/StringSubstringTemporary.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | static bool Accept(string s) => s == "oob"; 4 | 5 | public static bool Run() 6 | { 7 | string s = "foobar"; 8 | Accept(s.Substring(1, 3)); //FAIL: cl 9 | bool b = Accept(s.Substring(1, 3)); 10 | if (!b) 11 | return false; 12 | return Accept(s.Substring(1, 3)); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test/Float.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | float e = Math.E; 6 | float f = Math.PI; 7 | float sum = e + f; 8 | float q = 2.0 / 3; 9 | return e > 2.71 && e < 2.72 //FAIL: cl TODO if no double support 10 | && f > 3.14 && f < 3.15 11 | && sum > 5.85 && sum < 5.86 12 | && q > 0.66 && q < 0.67; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test/ObjectPtrToDynamic.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | int Foo = 42; 4 | 5 | static bool Check(Test p) 6 | { 7 | return p.Foo == 42; 8 | } 9 | 10 | public static bool Run() 11 | { 12 | Test# d = new Test(); //FAIL: cl 13 | Test p = d; 14 | Test p2; 15 | p2 = d; 16 | return p.Foo == 42 17 | && p2.Foo == 42 18 | && Check(d); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /test/OpLess.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int a = 1; 6 | int b = 2; 7 | double c = 3; //FAIL: cl if no double support 8 | double d = 3.5; 9 | byte[2] ba; 10 | ba[0] = 3; 11 | ba[1] = 200; 12 | return a < b 13 | && c < d 14 | && b < c 15 | && ba[0] < ba[1] 16 | && !(ba[1] < ba[0]); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /test/SortedDictionaryList.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | SortedDictionary()>() dict; //FAIL: cl 6 | dict.Add("zamek"); 7 | dict["zamek"].Add("castle"); 8 | dict["zamek"].Add("lock"); 9 | 10 | return dict.Count == 1 && dict["zamek"][0] == "castle" && dict["zamek"][1] == "lock"; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/StAssertCast.fu: -------------------------------------------------------------------------------- 1 | class Animal 2 | { 3 | internal string? Name; 4 | } 5 | 6 | class Cat : Animal 7 | { 8 | internal string? Food; 9 | } 10 | 11 | public static class Test 12 | { 13 | public static bool Run() 14 | { 15 | Cat() alik; 16 | alik.Food = "mice"; 17 | Animal! a = alik; 18 | assert a is Cat! c; 19 | return c.Food == "mice"; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /test/StThrowDestruct.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | static uint UintThrow() throws Exception 4 | { 5 | throw Exception("Foo"); 6 | } 7 | 8 | public static string() Outer() throws Exception 9 | { 10 | string() s = "bar"; //FAIL: cl 11 | UintThrow(); 12 | return s; 13 | } 14 | 15 | public static bool Run() 16 | { 17 | return true; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /test/Dictionary.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | Dictionary() dict; //FAIL: cl 6 | dict[1] = 10; 7 | dict.Clear(); 8 | dict[2] = 12; 9 | dict[2] = 20; 10 | dict[3] = 30; 11 | dict.Remove(1); //FAIL: py 12 | return dict.Count == 2 && dict[2] == 20 && dict[3] == 30 && dict.ContainsKey(2); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test/OpCondOr.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | static bool IsLetter(int c) 4 | => (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'); 5 | 6 | public static bool Run() 7 | { 8 | bool a = true; 9 | int[]? b = null; 10 | return (a || b[0] == 5) 11 | && (true || false) 12 | && (a || false) 13 | && (false || a) 14 | && IsLetter('f'); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /test/error/ThisInvalid.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | bool Foo!() 4 | { 5 | Test() o; 6 | this = o; // TODO 7 | return true; 8 | } 9 | 10 | bool Bar() => this.Foo(); //ERROR: Cannot call mutating method 'Foo' on a read-only reference 11 | 12 | public static bool Run() 13 | { 14 | Test o = this; //ERROR: 'this' not found 15 | return true; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /test/DictionaryDynamic.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | internal int X = 42; 4 | 5 | public static bool Run() 6 | { 7 | Dictionary() dict; //FAIL: cl 8 | dict["foo"] = new Test(); 9 | dict.Clear(); 10 | dict["bar"] = new Test(); 11 | dict["bar"].X++; 12 | return dict.Count == 1 && dict["bar"].X == 43 && dict.ContainsKey("bar"); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test/DynamicInit.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | int Foo = 42; 4 | 5 | public static bool Run() 6 | { 7 | Test# p = new Test(); //FAIL: cl 8 | Test# q = p; 9 | 10 | int[]# a = new int[2]; 11 | a[1] = 10; 12 | a[0] = 5; 13 | int[]# b = a; 14 | return p.Foo == 42 && q == p 15 | && a[0] == 5 && a[1] == 10 && b[0] == 5 && b[1] == 10 && b == a; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /test/OpEqualString.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | string() s = "foo"; //FAIL: cl 6 | string p = "foo"; 7 | #if TS 8 | native { 9 | // @ts-ignore 10 | } 11 | #endif 12 | return s == s 13 | && s == p 14 | && p == s 15 | && p == p 16 | && s == "foo" 17 | && p == "foo" 18 | && !(s == "bar"); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /test/SortedDictionary.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | SortedDictionary() dict; //FAIL: cl 6 | dict[1] = 10; 7 | dict.Clear(); 8 | dict[2] = 12; 9 | dict[2] = 20; 10 | dict[3] = 30; 11 | dict.Remove(1); //FAIL: py 12 | return dict.Count == 2 && dict[2] == 20 && dict[3] == 30 && dict.ContainsKey(2); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test/StringInterpolatedSubstring.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | string s = "barek"; 6 | string() s1 = $"^{s.Substring(1, 3)}$"; //FAIL: cl 7 | const byte[4] b = { 'f', 'o', 'o', 'b' }; 8 | string() s2 = $"^{Encoding.UTF8.GetString(b, 1, 2), 3}$"; //FAIL: py swift TODO 9 | return s1 == "^are$" && s2 == "^ oo$"; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/ConsoleErrorWriteLine.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | Console.Error.WriteLine("Hello"); //FAIL: swift TODO; cl 6 | string s = "World"; 7 | Console.Error.WriteLine(s); 8 | Console.Error.WriteLine(); 9 | int i = 42; 10 | Console.Error.WriteLine(i); 11 | Console.Error.WriteLine($"i={i:X}"); 12 | return true; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test/MethodShortIsVar.fu: -------------------------------------------------------------------------------- 1 | class Base 2 | { 3 | protected virtual void Foo() { } 4 | } 5 | 6 | class Derived : Base 7 | { 8 | internal bool Yes = true; 9 | } 10 | 11 | public static class Test 12 | { 13 | static bool Bar(Base b) => b is Derived d && d.Yes; //FAIL: c py swift cl TODO 14 | 15 | public static bool Run() 16 | { 17 | Derived() d; 18 | return Bar(d); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /test/RegexMatchReuse.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | public static bool Run() 4 | { 5 | Match() m; 6 | string() s = "foo bar"; //FAIL: cl 7 | if (!m.Find(s, "\\w{3}")) //FAIL: swift TODO 8 | return false; 9 | if (m.Value != "foo") 10 | return false; 11 | if (!m.Find(s, "b\\w\\w")) //FAIL: c leak TODO 12 | return false; 13 | return m.Value == "bar"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/ArrayStgInitField.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | int[5] Ints = 0; 4 | byte[5] Bytes = 0; 5 | bool[5] Bools = false; 6 | string?[5] Strings = null; 7 | 8 | public static bool Run() 9 | { 10 | Test() o; 11 | for (int i = 0; i < 5; i++) 12 | if (o.Ints[i] != 0 || o.Bytes[i] != 0 || o.Bools[i] || o.Strings[i] != null) 13 | return false; 14 | return true; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /test/HashSetPtr.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | HashSet() s; //FAIL: cl 6 | HashSet! p; //FAIL: swift TODO 7 | p = s; 8 | p.Add(42); 9 | p.Clear(); 10 | p.Add(1); 11 | s.Add(3); 12 | p.Add(2); 13 | p.Add(1); 14 | p.Remove(2); 15 | return p.Count == 2 && p.Contains(1) && p.Contains(3) && !p.Contains(2); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /test/MathFusedMultiplyAdd.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | double x = 2; //FAIL: cl if no double support 6 | double y = 3; 7 | double z = 1; 8 | float f = 2; 9 | float g = 3; 10 | float h = 1; 11 | f = Math.FusedMultiplyAdd(f, g, h); 12 | return Math.FusedMultiplyAdd(x, y, z) == 7 && f == 7; //FAIL: py need Python 3.13 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test/MathInfinity.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | float inf = Math.PositiveInfinity; 6 | float minusInf = Math.NegativeInfinity; 7 | return inf > 1e300 && minusInf < -1e300 //FAIL: cl TODO if no double support 8 | && Math.IsInfinity(inf) && Math.IsInfinity(minusInf) 9 | && !Math.IsFinite(inf) && !Math.IsFinite(minusInf); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/StForRangeDec.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int s = 0; 6 | for (int i = 3; i > 1; i--) 7 | s += i; 8 | 9 | int t = 0; 10 | for (int i = 3; i >= 1; i--) 11 | t += i; 12 | 13 | int one = 1; 14 | int u = 0; 15 | for (int i = 3; i >= one; i--) 16 | u += i; 17 | 18 | return s == 5 && t == 6 && u == 6; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /test/StForeachListPtr.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | static int Sum(List list) //FAIL: swift 4 | { 5 | int sum = 0; 6 | foreach (int i in list) 7 | sum += i; 8 | return sum; 9 | } 10 | 11 | public static bool Run() 12 | { 13 | List() list; //FAIL: cl 14 | list.Add(15); 15 | list.Add(5); 16 | list.Add(10); 17 | return Sum(list) == 30; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /test/StSwitchVarStringStg.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int a = 42; 6 | switch (a) { 7 | case 4: 8 | case 7: 9 | string() s1 = "foo"; //FAIL: cl 10 | return false; 11 | case 40: 12 | string() s2 = "bar"; 13 | return false; 14 | default: 15 | string() s3 = "quux"; 16 | break; 17 | } 18 | return true; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /test/MethodArgTempObjectStg.fu: -------------------------------------------------------------------------------- 1 | class Data 2 | { 3 | internal int X; 4 | } 5 | 6 | public static class Test 7 | { 8 | static Data() ReturnStorage() 9 | { 10 | Data() o; 11 | o.X = 42; 12 | return o; 13 | } 14 | 15 | static int AcceptPtr(Data d) 16 | { 17 | return d.X; 18 | } 19 | 20 | public static bool Run() 21 | { 22 | return AcceptPtr(ReturnStorage()) == 42; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /test/OpIsVar.fu: -------------------------------------------------------------------------------- 1 | class Base 2 | { 3 | protected virtual void Foo() { } 4 | } 5 | 6 | class Derived : Base 7 | { 8 | internal bool Ok() => true; 9 | } 10 | 11 | public static class Test 12 | { 13 | public static bool Run() 14 | { 15 | Derived() d; 16 | Base! b = d; 17 | return b is Derived ro && ro.Ok() //FAIL: c py swift cl TODO 18 | && b is Derived! rw && rw.Ok(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /test/StReturnThrows.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static void Foo() throws Exception 4 | { 5 | return; 6 | } 7 | 8 | public static byte GetByte() throws Exception 9 | { 10 | return 42; 11 | } 12 | 13 | public static float GetFloat() throws Exception 14 | { 15 | return GetByte(); 16 | } 17 | 18 | public static bool Run() 19 | { 20 | return true; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /test/CollectionPtrCycle.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | Test?[2] ArrayStg; 4 | Test?[]? ArrayPtr; 5 | List() ListStg; //FAIL: cl 6 | Dictionary() DictStg; 7 | 8 | public static bool Run() 9 | { 10 | Test() o; 11 | o.ArrayStg[0] = o; //FAIL: swift TODO memleak 12 | o.ArrayPtr = o.ArrayStg; 13 | o.ListStg.Add(o); 14 | o.DictStg[5] = o; 15 | return true; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /test/DictionaryPtr.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | Dictionary() dict; //FAIL: swift TODO; cl 6 | Dictionary! p; 7 | p = dict; 8 | p[1] = 10; 9 | p.Clear(); 10 | p[2] = 12; 11 | p[2] = 20; 12 | p[3] = 30; 13 | p.Remove(1); //FAIL: py 14 | return p.Count == 2 && p[2] == 20 && p[3] == 30 && p.ContainsKey(2); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /test/MethodSealed.fu: -------------------------------------------------------------------------------- 1 | abstract class Base 2 | { 3 | internal virtual bool Foo() //FAIL: cl 4 | { 5 | return false; 6 | } 7 | } 8 | 9 | sealed class Derived : Base 10 | { 11 | internal sealed bool Foo() 12 | { 13 | return true; 14 | } 15 | } 16 | 17 | public static class Test 18 | { 19 | public static bool Run() 20 | { 21 | Base# d = new Derived(); 22 | return d.Foo(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /test/StringSubstring2.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | public static bool Run() 4 | { 5 | string ptr = "barek"; 6 | int one = 1; 7 | string escaped = "hello\n"; 8 | return ptr.Substring(one, 3) != "ARE" 9 | && escaped.Substring(3, 3) == "lo\n" 10 | && escaped.Substring(3) == "lo\n" 11 | && escaped.Substring(3)[0] == 'l' 12 | && !(escaped.Substring(3, 3) == "LO\n"); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test/ArrayPtrMultiDim.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int[2][3] a; 6 | int[]![3] p = a; 7 | a[0][0] = 1; 8 | p[0][1] = 2; 9 | a[0][2] = 3; 10 | a[1][0] = 4; 11 | p[1][1] = 5; 12 | a[1][2] = 6; 13 | int sum = 0; 14 | for (int i = 0; i < 2; i++) 15 | for (int j = 0; j < 3; j++) 16 | sum += a[i][j]; 17 | return sum == 21; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /test/StContinueWhile.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int i = 0; 6 | int s = 0; 7 | while (i < 5) { 8 | if (++i == 2) 9 | continue; 10 | s += i; 11 | } 12 | int r = 0; 13 | i = 0; 14 | while (++i < 10) { 15 | if (i != 3) { 16 | r += i; 17 | continue; 18 | } 19 | break; 20 | } 21 | return s == 13 && r == 3; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /test/StringInterpolatedTemporary.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | static string() Produce(int i) => $"{i}"; //FAIL: cl 4 | 5 | static bool Accept(string s) => s == "42"; 6 | 7 | public static bool Run() 8 | { 9 | int i = 42; 10 | Accept($"{i}"); 11 | bool b = Accept($"{i}"); 12 | if (!b) 13 | return false; 14 | Accept($"{Produce(i)}"); 15 | return Accept($"{i}"); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /debian/control: -------------------------------------------------------------------------------- 1 | Source: fut 2 | Maintainer: Piotr Fusik 3 | Section: devel 4 | Priority: optional 5 | Standards-Version: 4.6.0 6 | Build-Depends: debhelper (>= 7), g++-13 7 | 8 | Package: fut 9 | Architecture: any 10 | Depends: ${shlibs:Depends} 11 | Description: Transpiles the Fusion programming langauge to 12 | C, C++, C#, D, Java, JavaScript, Python, Swift, TypeScript and OpenCL C. 13 | -------------------------------------------------------------------------------- /test/PreElif.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | #if true 6 | bool b = true; 7 | #elif false 8 | b = false; 9 | #elif true 10 | b = false; 11 | #endif 12 | 13 | #if false 14 | return false; 15 | #if true 16 | return false; 17 | #endif 18 | #elif false 19 | return false; 20 | #elif true 21 | return b; 22 | #else 23 | return false; 24 | #endif 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /test/StForeachDictionary.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | Dictionary() dict; //FAIL: cl 6 | dict[3] = 15; 7 | dict[1] = 5; 8 | dict[2] = 10; 9 | int keySum = 0; 10 | int valueSum = 0; 11 | foreach ((int key, int value) in dict) { 12 | keySum += key; 13 | valueSum += value; 14 | } 15 | return keySum == 6 && valueSum == 30; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /test/error/OpNotEqualStgDynamic.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | public static bool Run() 4 | { 5 | Test() o; 6 | Test# d = new Test(); 7 | return o != null //ERROR: Cannot compare 'Test()' with 'null' 8 | && o == o //ERROR: Cannot compare 'Test()' with 'Test()' 9 | && o != d //ERROR: Cannot compare 'Test()' with 'Test#' 10 | && d != o; //ERROR: Cannot compare 'Test#' with 'Test()' 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/ArrayListPtr.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | List() l1; //FAIL: cl 6 | List() l2; 7 | l1.Add(5); 8 | l1.Add(10); 9 | l1.Add(15); 10 | l2.Add(3); 11 | l2.Add(6); 12 | List![2] a; //FAIL: swift TODO; java 13 | a[0] = l1; 14 | a[1] = l2; 15 | return a[0] == l1 && a[0].Count == 3 16 | && a[1] == l2 && a[1].Count == 2; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /test/DynamicAssign.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | int Foo = 42; 4 | 5 | public static bool Run() 6 | { 7 | Test# p; //FAIL: cl 8 | p = new Test(); 9 | Test# q; 10 | q = p; 11 | 12 | int[]# a; 13 | a = new int[2]; 14 | a[0] = 5; 15 | a[1] = 10; 16 | int[]# b; 17 | b = a; 18 | return p.Foo == 42 && q == p 19 | && a[0] == 5 && a[1] == 10 && b[0] == 5 && b[1] == 10 && b == a; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /test/error/OpIsNotClass.fu: -------------------------------------------------------------------------------- 1 | public class Base 2 | { 3 | } 4 | 5 | public class Test : Base 6 | { 7 | public static bool Run() 8 | { 9 | Test() o; 10 | Base p = o; 11 | return p is int //ERROR: Right hand side of the 'is' operator must be a class name 12 | && p is int i //ERROR: 'is' with non-reference type 13 | && p is 5; //ERROR: Right hand side of the 'is' operator must be a class name 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/error/TypeNames.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | public static bool Run() 4 | { 5 | List l = 5; //ERROR: Cannot convert '5' to 'List' 6 | Dictionary l = "wat"; //ERROR: Cannot convert 'string' to 'Dictionary' 7 | int[]! a = 42; //ERROR: Cannot convert '42' to 'int[]!' 8 | int[]# da = 10; //ERROR: Cannot convert '10' to 'int[]#' 9 | return true; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/ListObjectStg.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | int Foo = 42; 4 | 5 | public static bool Run() 6 | { 7 | List() list; //FAIL: cl 8 | list.Add(); 9 | list[0].Foo = 0; 10 | list.Clear(); 11 | list.Add(); 12 | list[0].Foo = 2; 13 | list.Add(); 14 | list.Insert(0); 15 | list[0].Foo = 1; 16 | return list.Count == 3 && list[0].Foo == 1 && list[1].Foo == 2 && list[2].Foo == 42; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /test/OpAddString.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | string() s = "foo"; //FAIL: cl 6 | string p = "bar"; 7 | return s + s == "foofoo" 8 | && s + p == "foobar" 9 | && p + s == "barfoo" 10 | && p + p == "barbar" 11 | && s + "quux" == "fooquux" 12 | && "quux" + s == "quuxfoo" 13 | && p + "quux" == "barquux" 14 | && "quux" + p == "quuxbar"; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /test/OpIsVarDynamic.fu: -------------------------------------------------------------------------------- 1 | class Base 2 | { 3 | protected virtual void Foo() { } 4 | } 5 | 6 | class Derived : Base 7 | { 8 | internal bool Ok = true; 9 | } 10 | 11 | public static class Test 12 | { 13 | public static bool Run() 14 | { 15 | Base# p = new Derived(); 16 | if (p is Derived# d) { //FAIL: c py swift TODO; cl 17 | if (p is Derived! r) 18 | return r.Ok; 19 | } 20 | return false; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /test/StIfIsVar.fu: -------------------------------------------------------------------------------- 1 | class Base 2 | { 3 | public virtual bool IsDerived() => false; 4 | } 5 | 6 | class Derived : Base 7 | { 8 | public override bool IsDerived() => true; 9 | } 10 | 11 | public static class Test 12 | { 13 | public static bool Run() 14 | { 15 | Derived() d; 16 | Base! b = d; 17 | if (b is Derived ro) //FAIL: c py swift cl TODO 18 | return ro.IsDerived(); 19 | return false; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /test/error/ClassAbstractInstance.fu: -------------------------------------------------------------------------------- 1 | public abstract class Test 2 | { 3 | int X; 4 | 5 | public static bool Run() 6 | { 7 | Test() o; //ERROR: Cannot instantiate abstract class 8 | Test()[3] a; //ERROR: Cannot instantiate abstract class 9 | Test# p = new Test(); //ERROR: Cannot instantiate abstract class 10 | p = new Test { X = 5 }; //ERROR: Cannot instantiate abstract class 11 | return true; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/error/MethodOverrideMutatingMismatch.fu: -------------------------------------------------------------------------------- 1 | abstract class Base 2 | { 3 | public virtual void Foo() 4 | { 5 | } 6 | public abstract void Bar!(); 7 | } 8 | 9 | class Derived : Base 10 | { 11 | public override void Foo!() //ERROR: Mutating method cannot override a non-mutating method 12 | { 13 | } 14 | public override void Bar() //ERROR: Non-mutating method cannot override a mutating method 15 | { 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /test/DynamicArrayMultiDim.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int[]#[3] a = new int[2][3]; //FAIL: cs js ts TODO; cl 6 | a[0][0] = 1; 7 | a[0][1] = 2; 8 | a[0][2] = 3; 9 | a[1][0] = 4; 10 | a[1][1] = 5; 11 | a[1][2] = 6; 12 | int sum = 0; 13 | for (int i = 0; i < 2; i++) 14 | for (int j = 0; j < 3; j++) 15 | sum += a[i][j]; 16 | return sum == 21; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /test/IntMinMaxValue.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int intZero = 0; 6 | long longZero = 0; 7 | return int.MinValue == -0x80000000 && int.MaxValue == 0x7fffffff && int.MinValue < intZero 8 | && long.MinValue == -0x8000000000000000 && long.MaxValue == 0x7fffffffffffffff && long.MinValue < longZero 9 | && short.MinValue == -0x8000 && short.MaxValue == 0x7fff; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/ListList.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | List()>() lol; //FAIL: cl 6 | lol.Add(); 7 | lol[0].Add(11); 8 | lol[0].Add(12); 9 | lol.Add(); 10 | lol[1].Add(21); 11 | lol[1].Add(22); 12 | return lol.Count == 2 && lol[0].Count == 2 && lol[1].Count == 2 13 | && lol[0][0] == 11 && lol[0][1] == 12 14 | && lol[1][0] == 21 && lol[1][1] == 22; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /test/Stack.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | Stack() s; //FAIL: cl 6 | s.Push(42); 7 | s.Clear(); 8 | s.Push(5); 9 | s.Push(10); 10 | s.Push(15); 11 | s.Pop(); 12 | Stack() sb; 13 | sb.Push(200); 14 | int b = 222; 15 | sb.Push(b); 16 | return s.Count == 2 && s.Pop() == 10 && s.Peek() == 5 17 | && sb.Pop() == 222 && sb.Pop() == 200; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /test/DictionaryObjectStg.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | int Foo = 42; //FAIL: c TODO 4 | 5 | public static bool Run() 6 | { 7 | Dictionary() dict; //FAIL: cl 8 | dict.Add(1); 9 | dict.Clear(); 10 | dict.Add(1); 11 | dict.Add(2); 12 | dict.Add(3); 13 | dict[3].Foo = 30; 14 | dict.Remove(1); 15 | return dict.Count == 2 && dict[2].Foo == 42 && dict[3].Foo == 30 && dict.ContainsKey(2); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /test/MethodArgTempObjectStgDestructor.fu: -------------------------------------------------------------------------------- 1 | class Data 2 | { 3 | internal string() S; //FAIL: cl 4 | } 5 | 6 | public static class Test 7 | { 8 | static Data() ReturnStorage() 9 | { 10 | Data() o; 11 | o.S = "foo"; 12 | return o; 13 | } 14 | 15 | static string AcceptPtr(Data d) 16 | { 17 | return d.S; 18 | } 19 | 20 | public static bool Run() 21 | { 22 | return AcceptPtr(ReturnStorage()) == "foo"; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /test/MethodParamDefault.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | static bool Foo(int i = 42, bool b = true) 4 | { 5 | return i == 42 && b; 6 | } 7 | 8 | const int DefaultX = 5; 9 | 10 | public static bool Bar(int x = DefaultX) => x == DefaultX; 11 | 12 | public static bool Quux(int x = DefaultX + 1) => x == DefaultX + 1; 13 | 14 | public static bool Run() 15 | { 16 | return Foo() && Bar() && Quux(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /test/ConstEnum.fu: -------------------------------------------------------------------------------- 1 | public enum DayOfWeek 2 | { 3 | Sunday, 4 | Monday, 5 | Tuesday, 6 | Wednesday, 7 | Thursday, 8 | Friday, 9 | Saturday 10 | } 11 | 12 | public static class Test 13 | { 14 | public const DayOfWeek Worst = DayOfWeek.Monday; 15 | 16 | public static bool Run() 17 | { 18 | const DayOfWeek worst = DayOfWeek.Monday; 19 | return Worst == DayOfWeek.Monday 20 | && worst == DayOfWeek.Monday; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /test/ObjectPtrToBase.fu: -------------------------------------------------------------------------------- 1 | public class Base 2 | { 3 | public int Foo() => 42; 4 | } 5 | 6 | public class Test : Base 7 | { 8 | static bool Check(Base p) 9 | { 10 | return p.Foo() == 42; 11 | } 12 | 13 | public static bool Run() 14 | { 15 | Test() o; 16 | Base b = o; 17 | Test p = o; 18 | Base b2; 19 | b2 = p; 20 | return b.Foo() == 42 21 | && b2.Foo() == 42 22 | && Check(o) 23 | && Check(p); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /test/error/MethodOverrideParameterCountMismatch.fu: -------------------------------------------------------------------------------- 1 | abstract class Base 2 | { 3 | public virtual void Foo(int x) 4 | { 5 | } 6 | } 7 | 8 | class Derived : Base 9 | { 10 | public override void Foo() //ERROR: Fewer parameters than the overridden method 11 | { 12 | } 13 | } 14 | 15 | class AnotherDerived : Base 16 | { 17 | public override void Foo(int x, int y) //ERROR: More parameters than the overridden method 18 | { 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /test/ListDictionary.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | List()>() lod; //FAIL: cl 6 | lod.Add(); 7 | lod[0][5] = 11; 8 | lod[0][10] = 12; 9 | lod.Add(); 10 | lod[1][4] = 21; 11 | lod[1][8] = 22; 12 | return lod.Count == 2 && lod[0].Count == 2 && lod[1].Count == 2 13 | && lod[0][5] == 11 && lod[0][10] == 12 14 | && lod[1][4] == 21 && lod[1][8] == 22; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /test/ListStack.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | List()>() los; //FAIL: cl 6 | los.Add(); 7 | los[0].Push(11); 8 | los[0].Push(12); 9 | los.Add(); 10 | los[1].Push(21); 11 | los[1].Push(22); 12 | return los.Count == 2 && los[0].Count == 2 && los[1].Count == 2 13 | && los[0].Pop() == 12 && los[0].Peek() == 11 14 | && los[1].Pop() == 22 && los[1].Peek() == 21; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /test/OpGreaterOrEqual.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int a = 1; 6 | int b = 2; 7 | double c = 3; //FAIL: cl if no double support 8 | double d = 3.5; 9 | byte[2] ba; 10 | ba[0] = 3; 11 | ba[1] = 200; 12 | return !(a >= b) && a + 1 >= b 13 | && !(c >= d) && d - 0.5 >= c 14 | && d >= a 15 | && ba[1] >= ba[0] 16 | && !(ba[0] >= ba[1]) 17 | && !(ba[1] >= 256); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /test/OpIs.fu: -------------------------------------------------------------------------------- 1 | class Base 2 | { 3 | protected virtual void Foo() { } 4 | } 5 | 6 | class Derived : Base 7 | { 8 | } 9 | 10 | class NotThis : Base 11 | { 12 | } 13 | 14 | public static class Test 15 | { 16 | public static bool Run() 17 | { 18 | Derived() d; 19 | Base b = d; 20 | if (b == d ? false : b is Derived) //FAIL: c cl TODO 21 | return false; 22 | return b is Derived 23 | && !(b is NotThis) & b is Derived; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /test/StAssertCastDynamic.fu: -------------------------------------------------------------------------------- 1 | class Animal 2 | { 3 | internal string? Name; 4 | } 5 | 6 | class Cat : Animal 7 | { 8 | internal string? Food; 9 | } 10 | 11 | public static class Test 12 | { 13 | public static bool Run() 14 | { 15 | Cat# alik = new Cat(); //FAIL: cl 16 | alik.Food = "mice"; 17 | Animal# a = alik; 18 | assert a is Cat# c; 19 | assert a is Cat c2; 20 | return c.Food == "mice" && c2.Food == "mice"; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /test/StContinueDoWhile.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int i = 0; 6 | int s = 0; 7 | do { 8 | i++; 9 | if (i == 2 || i == 5) 10 | continue; 11 | s += i; 12 | } while (i > 0 && i < 5); 13 | int r = 0; 14 | i = 0; 15 | do { 16 | if (i != 3) { 17 | r += i; 18 | continue; 19 | } 20 | break; 21 | } while (++i < 5); 22 | return s == 8 && r == 3; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /test/StFor.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int s = 0; 6 | for (int i = 0; i < 5; i++) 7 | s += i; 8 | 9 | int t = 0; 10 | for (int i = 0; i <= 5; i++) 11 | t += i; 12 | 13 | int u = 0; 14 | for (int i = 0; i < 5; ) 15 | u += i++; 16 | 17 | int v = 0; 18 | for (int i = 0; i <= 5; ) 19 | v += i++; 20 | 21 | return s == 10 && t == 15 && u == 10 && v == 15; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /test/ConsoleWriteLine.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | Console.WriteLine("Hello"); 6 | string s = "World"; 7 | Console.WriteLine(s); 8 | Console.WriteLine(); 9 | int i = 42; 10 | Console.WriteLine(i); 11 | Console.WriteLine($"i={i:X}"); 12 | Console.WriteLine($"i={i:X}={i}"); 13 | long l = 5; 14 | Console.WriteLine(l); 15 | Console.WriteLine($"l={l}"); 16 | return true; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /test/ListAll.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | int Value; 4 | 5 | public static bool Run() 6 | { 7 | List() list; //FAIL: cl 8 | Test# t = new Test(); 9 | t.Value = 5; 10 | list.Add(t); 11 | t = new Test(); 12 | t.Value = 15; 13 | list.Add(t); 14 | t = new Test(); 15 | t.Value = 10; 16 | list.Add(t); 17 | List() empty; 18 | return list.All(it => it.Value > 4) && empty.All(it => false); //FAIL: c 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /test/ListObjectStgDestr.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | string() Foo = ""; 4 | 5 | public static bool Run() 6 | { 7 | List() list; //FAIL: cl 8 | list.Add(); 9 | list[0].Foo = "foo"; 10 | list.Clear(); 11 | list.Add(); 12 | list[0].Foo = "bar"; 13 | list.Add(); 14 | list.Insert(0); 15 | list[0].Foo = "quux"; 16 | return list.Count == 3 && list[0].Foo == "quux" && list[1].Foo == "bar" && list[2].Foo == ""; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /test/error/StringInterpolatedFormatError.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int i = 42; 6 | float f = 10.5; 7 | string() s = $"|{i:F5}|"; //ERROR: Invalid format 8 | string() s2 = $"|{f:X2}|"; //ERROR: Invalid format 9 | string() s3 = $"{s:D10}"; //ERROR: Invalid format 10 | string() s4 = $"{i,10:X5}"; //ERROR: Cannot format an integer with both width and precision 11 | return true; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/SortedDictionaryObjectStg.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | int Foo = 42; 4 | 5 | public static bool Run() 6 | { 7 | SortedDictionary() dict; //FAIL: cl 8 | dict.Add(1); 9 | dict.Clear(); 10 | dict.Add(1); 11 | dict.Add(2); 12 | dict[2].Foo = 20; 13 | dict.Add(3); 14 | dict[3].Foo = 30; 15 | dict.Remove(1); 16 | return dict.Count == 2 && dict[2].Foo == 20 && dict[3].Foo == 30 && dict.ContainsKey(2); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /test/error/OpIsNotPtr.fu: -------------------------------------------------------------------------------- 1 | public class Base 2 | { 3 | } 4 | 5 | public class Test : Base 6 | { 7 | public static bool Run() 8 | { 9 | int i = 5; 10 | Test() o; 11 | Base! p = o; 12 | return i is Test //ERROR: Left hand side of the 'is' operator must be an object reference 13 | && o is Test //ERROR: Left hand side of the 'is' operator must be an object reference 14 | && p is Test() o2; //ERROR: 'is' with non-reference type 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /test/ClassAbstractDerived.fu: -------------------------------------------------------------------------------- 1 | class Base 2 | { 3 | internal bool Foo() => true; 4 | } 5 | 6 | abstract class AbstractDerived : Base 7 | { 8 | internal abstract bool Bar(); //FAIL: cl 9 | } 10 | 11 | class MostDerived : AbstractDerived 12 | { 13 | internal override bool Bar() => Foo(); 14 | } 15 | 16 | public static class Test 17 | { 18 | public static bool Run() 19 | { 20 | AbstractDerived# d = new MostDerived(); 21 | return d.Bar(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /test/EncodingGetString.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | static string() GetInitial(byte[] a) => Encoding.UTF8.GetString(a, 0, 1); 4 | 5 | public static bool Run() 6 | { 7 | byte[6] a; 8 | a[0] = 'x'; 9 | a[1] = 'f'; 10 | a[2] = 'o'; 11 | a[3] = 'o'; 12 | a[4] = 'b'; 13 | a[5] = 'a'; 14 | string() s = Encoding.UTF8.GetString(a, 1, 3); //FAIL: cl 15 | string() s2 = GetInitial(a); 16 | return s == "foo" && s2 == "x"; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /test/ListSortedDictionary.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | List()>() lod; //FAIL: cl 6 | lod.Add(); 7 | lod[0][5] = 11; 8 | lod[0][10] = 12; 9 | lod.Add(); 10 | lod[1][4] = 21; 11 | lod[1][8] = 22; 12 | return lod.Count == 2 && lod[0].Count == 2 && lod[1].Count == 2 13 | && lod[0][5] == 11 && lod[0][10] == 12 14 | && lod[1][4] == 21 && lod[1][8] == 22; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /test/StSwitchUTF8.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | byte[4] a; 6 | a[0] = 'f'; 7 | a[1] = 'o'; 8 | a[2] = 'o'; 9 | a[3] = 'b'; 10 | int len = 2; 11 | switch (Encoding.UTF8.GetString(a, 1, len)) { 12 | case "": 13 | case "foob": //FAIL: c TODO gcc memcmp bounds 14 | return false; 15 | case "bar": 16 | case "oo": 17 | return true; 18 | default: 19 | return false; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /test/ArrayStgDynamic.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | int Id; 4 | Test#?[2] F; 5 | 6 | public static bool Run() 7 | { 8 | Test#?[2] a; //FAIL: cl 9 | a[0] = new Test(); 10 | a[0].Id = 5; 11 | a[1] = new Test(); 12 | a[1].Id = 10; 13 | Test() o; 14 | o.F[0] = new Test(); 15 | o.F[0].Id = 15; 16 | o.F[1] = new Test(); 17 | o.F[1].Id = 20; 18 | return a[0].Id == 5 && a[1].Id == 10 19 | && o.F[0].Id == 15 && o.F[1].Id == 20; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /test/EncodingGetBytes.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | byte[8] a; 6 | string s = "foo"; 7 | Encoding.UTF8.GetBytes("bar", a, 3); 8 | byte[]! p = a; 9 | Encoding.UTF8.GetBytes(s, p, 0); 10 | if (a[0] == 'f') 11 | Encoding.UTF8.GetBytes("ek", a, 6); 12 | return a[0] == 'f' && a[1] == 'o' && a[2] == 'o' 13 | && a[3] == 'b' && a[4] == 'a' && a[5] == 'r' 14 | && a[6] == 'e' && a[7] == 'k'; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /test/MathMaxMin.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | nint n = 1024; 6 | long l = 0x1000000; 7 | l *= l; 8 | return Math.Min(-5, 10) == -5 && Math.Max(-5, 10) == 10 && Math.Min(n, -n) == -n && Math.Max(n, -n) == n && Math.Max(l, l) == l && Math.Min(0, l) == 0 //FAIL: cl TODO 9 | && Math.Min(-3, 10.5) == -3 && Math.Max(-3, 10.5) == 10.5; //FAIL: swift TODO https://github.com/swiftlang/swift/issues/76416 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/MethodOverride.fu: -------------------------------------------------------------------------------- 1 | abstract class Base 2 | { 3 | internal virtual bool Foo() //FAIL: cl 4 | { 5 | return false; 6 | } 7 | } 8 | 9 | class Derived : Base 10 | { 11 | internal override bool Foo() 12 | { 13 | return true; 14 | } 15 | 16 | internal bool Bar() 17 | { 18 | return Foo(); 19 | } 20 | } 21 | 22 | public static class Test 23 | { 24 | public static bool Run() 25 | { 26 | Derived() d; 27 | return d.Foo() && d.Bar(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /test/OpBoolLogic.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | bool t = true; 6 | bool f = false; 7 | t &= !f; 8 | t &= t && !f; 9 | f |= !t; 10 | t ^= f; 11 | int five = 5; 12 | return (t & !f) 13 | && (t | f) 14 | && (t ^ f) 15 | && (t & (t == true)) 16 | && (t & (five < 10)) 17 | && (f | (t == true)) 18 | && (f | (five > 2)) 19 | && (f ^ (t == true)) 20 | && (f ^ (five <= 5)); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /test/StReturnDynamic.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | int Foo = 42; 4 | 5 | static Test# CreateTest() => new Test(); //FAIL: cl 6 | 7 | static int[]# CreateIntArray() 8 | { 9 | int[]# a = new int[2]; 10 | a[0] = 5; 11 | a[1] = 10; 12 | return a; 13 | } 14 | 15 | public static bool Run() 16 | { 17 | Test# p = CreateTest(); 18 | CreateTest(); 19 | int[]# a = CreateIntArray(); 20 | return p.Foo == 42 && a[0] == 5 && a[1] == 10; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /test/StringEndsWith.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | public static bool Run() 4 | { 5 | string() s = "foobar"; //FAIL: cl 6 | string p = "foobar"; 7 | return s.EndsWith("") 8 | && s.EndsWith("bar") 9 | && s.EndsWith("foobar") 10 | && !s.EndsWith("foo") 11 | && p.EndsWith("") 12 | && p.EndsWith("bar") 13 | && p.EndsWith("foobar") 14 | && !p.EndsWith("foo") 15 | && "afoobar".EndsWith(s) 16 | && "afoobar".EndsWith(p); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /test/error/PreUnknown.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | #iftrue //ERROR: Invalid expression //ERROR: Expected ';', got unknown preprocessor directive 6 | #foo //ERROR: Expected ';', got unknown preprocessor directive 7 | #elf //ERROR: Expected ';', got unknown preprocessor directive 8 | #enlarge //ERROR: Expected ';', got unknown preprocessor directive 9 | return true; //ERROR: Expected ';', got 'return' 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /fut.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | false 5 | Exe 6 | net8.0 7 | LatestMajor 8 | false 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /test/MethodOverrideForward.fu: -------------------------------------------------------------------------------- 1 | class Derived : Base 2 | { 3 | internal override bool Foo() //FAIL: cl 4 | { 5 | return true; 6 | } 7 | 8 | internal bool Bar() 9 | { 10 | return Foo(); 11 | } 12 | } 13 | 14 | abstract class Base 15 | { 16 | internal virtual bool Foo() 17 | { 18 | return false; 19 | } 20 | } 21 | 22 | public static class Test 23 | { 24 | public static bool Run() 25 | { 26 | Derived() d; 27 | return d.Foo() && d.Bar(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /test/MethodParamObjectStg.fu: -------------------------------------------------------------------------------- 1 | class Data 2 | { 3 | internal int X; 4 | } 5 | 6 | public static class Test 7 | { 8 | static Data() ReturnStorage() 9 | { 10 | Data() o; 11 | o.X = 42; 12 | return o; 13 | } 14 | 15 | static int AcceptStorage(Data() d) 16 | { 17 | return d.X; 18 | } 19 | 20 | public static bool Run() 21 | { 22 | Data() o; 23 | o.X = 5; 24 | return AcceptStorage(o) == 5 25 | && AcceptStorage(ReturnStorage()) == 42; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /test/MethodVirtualThrows.fu: -------------------------------------------------------------------------------- 1 | public abstract class Base 2 | { 3 | internal virtual void Foo() throws Exception //FAIL: cl 4 | { 5 | } 6 | 7 | public uint Bar() throws Exception 8 | { 9 | Foo(); 10 | return 42; 11 | } 12 | } 13 | 14 | public class Derived : Base 15 | { 16 | internal override void Foo() throws Exception 17 | { 18 | } 19 | } 20 | 21 | public static class Test 22 | { 23 | public static bool Run() 24 | { 25 | return true; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /test/DictionaryObjectStgPublicConstructor.fu: -------------------------------------------------------------------------------- 1 | public class Test 2 | { 3 | int Foo = 42; 4 | 5 | public Test() 6 | { 7 | } 8 | 9 | public static bool Run() 10 | { 11 | Dictionary() dict; //FAIL: cl 12 | dict.Add(1); 13 | dict.Clear(); 14 | dict.Add(1); 15 | dict.Add(2); 16 | dict.Add(3); 17 | dict[3].Foo = 30; 18 | dict.Remove(1); 19 | return dict.Count == 2 && dict[2].Foo == 42 && dict[3].Foo == 30 && dict.ContainsKey(2); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /test/error/StringAssignNull.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | static void Foo(string s) 4 | { 5 | } 6 | 7 | static string ReturnMismatch() => null; //ERROR: Cannot convert 'null' to 'string' 8 | 9 | public static bool Run() 10 | { 11 | string() s = null; //ERROR: Cannot convert 'null' to 'string()' 12 | string p = null; //ERROR: Cannot convert 'null' to 'string' 13 | Foo(null); //ERROR: Cannot convert 'null' to 'string' 14 | return true; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /test/OpMul.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | static int GetXPixelsPerMeter() 4 | { 5 | return 11811; 6 | } 7 | 8 | public static float GetXPixelsPerInch(int pixelsPerMeter) => GetXPixelsPerMeter() * 0.0254; 9 | 10 | public static bool Run() 11 | { 12 | int a = 2; 13 | int b = 3; 14 | double c = 10.5; //FAIL: cl if no double support 15 | double d = 4; 16 | return a * b == 6 17 | && c * d == 42 18 | && a * c == 21 19 | && c * b == 31.5; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /test/StAssert.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | static bool Eq(int x, int y) => x == y; 4 | 5 | public static bool Run() 6 | { 7 | int i = 5; 8 | string s = "foo"; 9 | assert i > 0; 10 | assert i > 0, "i must be positive"; 11 | switch (i) { 12 | case 5: 13 | break; 14 | case 42: 15 | assert false, "NO!!!"; 16 | default: 17 | assert false; 18 | } 19 | assert s == "foo"; 20 | assert Eq(i, 5); 21 | return s == "foo" && Eq(i, 5); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /test/MathAbs.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int i = Math.Abs(-1000); 6 | nint n = 1024; 7 | long l = -1000000000; 8 | int j = Math.Abs(l); 9 | l *= i; 10 | float f = -10.5; 11 | f = Math.Abs(f); 12 | double d = Math.Abs(-1e200); //FAIL: cl if no double support 13 | return i == 1000 14 | && Math.Abs(n) == 1024 15 | && j == 1000000000 16 | && Math.Abs(l) == -l 17 | && f == 10.5 18 | && d == 1e200; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /test/OpIsVarIf.fu: -------------------------------------------------------------------------------- 1 | class Base 2 | { 3 | protected virtual void Foo() { } 4 | } 5 | 6 | class Derived : Base 7 | { 8 | internal bool Ok() => true; 9 | } 10 | 11 | public static class Test 12 | { 13 | public static bool Run() 14 | { 15 | Derived() d; 16 | Base!? b = d; 17 | if (b != null) 18 | if (b is Derived ro && !ro.Ok()) //FAIL: c py swift cl TODO 19 | return false; 20 | else if (b is Derived! rw && rw.Ok()) 21 | return true; 22 | return false; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /test/error/BaseMemberDuplicate.fu: -------------------------------------------------------------------------------- 1 | public class Base 2 | { 3 | public const int Const = 0; 4 | protected int Field; 5 | public int Method() => 0; 6 | } 7 | 8 | public class Derived : Base 9 | { 10 | public const int Const = 1; //ERROR: Duplicate definition of 'Const' in base class 'Base' 11 | protected int Field; //ERROR: Duplicate definition of 'Field' in base class 'Base' 12 | public int Method() => 1; //ERROR: Method defined in base class 'Base'. Did you mean 'override'? 13 | } 14 | -------------------------------------------------------------------------------- /test/ListArrayStg.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | List() list; //FAIL: cl 6 | list.Add(); 7 | list[0][0] = 100; 8 | list[0][1] = 200; 9 | list.Clear(); 10 | list.Add(); 11 | list[0][0] = 10; 12 | list[0][1] = 11; 13 | list.Add(); 14 | list.Insert(0); 15 | list[0][0] = 20; 16 | list[0][1] = 21; 17 | return list.Count == 3 && list[0][0] == 20 && list[0][1] == 21 && list[1][0] == 10 && list[1][1] == 11; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /test/DictionaryDictionary.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | Dictionary()>() dict; //FAIL: cl 6 | dict.Add("en"); 7 | dict["en"][2] = "two"; 8 | dict["en"][4] = "four"; 9 | dict.Add("pl"); 10 | dict["pl"][2] = "dwa"; 11 | dict["pl"][4] = "cztery"; 12 | return dict.Count == 2 13 | && dict["en"][2] == "two" && dict["en"][4] == "four" 14 | && dict["pl"][2] == "dwa" && dict["pl"][4] == "cztery"; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /test/StForNotRange.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int s = 0; 6 | 7 | for (int i = 0; i < 5; i++) 8 | s += ++i; 9 | 10 | int n = 2; 11 | for (int i = 0; i < n; i++) { 12 | s += i; 13 | if (i == 1) 14 | n++; 15 | } 16 | 17 | for (int i = 0; i < 8; i += n) { 18 | s += i; 19 | if (i == 3) 20 | n++; 21 | } 22 | 23 | for (int i = 1; i < 9; i *= 2) 24 | s += i; 25 | 26 | return s == 9 + 3 + 10 + 15; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /test/StSwitchVar.fu: -------------------------------------------------------------------------------- 1 | public static class Test 2 | { 3 | public static bool Run() 4 | { 5 | int a = 42; 6 | switch (a) { 7 | case 4: 8 | case 7: 9 | int b = 5; 10 | return b != 5; 11 | case 40 + 2: 12 | switch (++a) { 13 | case 43: 14 | switch (a++) { 15 | case 43: 16 | return a == 44; 17 | default: 18 | return false; 19 | } 20 | default: 21 | return false; 22 | } 23 | default: 24 | int c = 7; 25 | return c != 7; 26 | } 27 | } 28 | } 29 | --------------------------------------------------------------------------------