diff --git a/tests/js/Main.js b/tests/js/Main.js deleted file mode 100644 index 3815b9e..0000000 --- a/tests/js/Main.js +++ /dev/null @@ -1,505 +0,0 @@ -import { Mocha_runTests, Test_ftestCaseAsync, Test_ftestCase, Expect_notEqual, Test_TestCaseBuilder__Zero, Expect_containsAll, Test_TestCaseBuilder__Delay_1505, Test_TestCaseBuilder__Run_3A5B6456, FocusState, Test_ptestCaseAsync, Test_ptestCase, Expect_isNotInfinity, Expect_floatGreaterThanOrClose, Expect_floatLessThanOrClose, AccuracyModule_low, Expect_floatClose, Expect_throws, Expect_isNotNaN, Expect_isNull, Expect_isNotNull, Expect_isNone, Expect_wantSome, Expect_isSome, Expect_wantError, Expect_isError, Expect_stringContains, Expect_wantOk, Expect_isNonEmpty, Expect_isEmpty, Expect_throwsC, Expect_isOk, Expect_isFalse, Expect_isTrue, Test_testCase, Test_testCaseAsync, Test_testList, Test_testSequenced } from "./fable_modules/Fable.Mocha.2.17.0/Mocha.fs.js"; -import { singleton } from "./fable_modules/fable-library.4.1.4/AsyncBuilder.js"; -import { sleep } from "./fable_modules/fable-library.4.1.4/Async.js"; -import { contains, ofArray, singleton as singleton_1 } from "./fable_modules/fable-library.4.1.4/List.js"; -import { equals as equals_1, defaultOf, int32ToString, structuralHash, assertEqual } from "./fable_modules/fable-library.4.1.4/Util.js"; -import { anonRecord_type, equals, class_type, decimal_type, string_type, float64_type, bool_type, int32_type } from "./fable_modules/fable-library.4.1.4/Reflection.js"; -import { toFail, printf, toText } from "./fable_modules/fable-library.4.1.4/String.js"; -import { FSharpResult$2 } from "./fable_modules/fable-library.4.1.4/Choice.js"; -import { toString } from "./fable_modules/fable-library.4.1.4/Types.js"; -import { Test_TestCaseBuilder_$ctor_Z7EF1EC3F } from "./fable_modules/Fable.Mocha.2.17.0/Mocha.fs.js"; - -export const tests_sequential = Test_testSequenced(Test_testList("Sequential", ofArray([Test_testCaseAsync("one", singleton.Delay(() => singleton.Bind(sleep(1000), () => singleton.Return(void 0)))), Test_testCase("sync one", () => { - Expect_isTrue(true)("this should work"); -}), Test_testCaseAsync("two", singleton.Delay(() => singleton.Bind(sleep(1000), () => singleton.Return(void 0)))), Test_testCase("sync two", () => { - Expect_isTrue(true)(""); -}), Test_testList("Many", singleton_1(Test_testCase("syncThree", () => { - Expect_isTrue(true)(""); -}))), Test_testCaseAsync("three", singleton.Delay(() => singleton.Bind(sleep(1000), () => { - Expect_isTrue(true)("this should work"); - return singleton.Zero(); -})))]))); - -export const tests_basic = Test_testList("Basic", ofArray([Test_testCase("testCase works with numbers", () => { - let copyOfStruct, arg, arg_1; - const actual = 2; - if ((actual === 2) ? true : !(new Function("try {return this===window;}catch(e){ return false;}"))()) { - assertEqual(actual, 2, "Should be equal"); - } - else { - throw new Error(contains((copyOfStruct = actual, int32_type), ofArray([int32_type, bool_type, float64_type, string_type, decimal_type, class_type("System.Guid")]), { - Equals: equals, - GetHashCode: structuralHash, - }) ? ((arg = int32ToString(2), (arg_1 = int32ToString(actual), toText(printf("Expected:
%s

Actual:
%s

Message:
%s
"))(arg)(arg_1)("Should be equal")))) : toText(printf("Expected:
%A

Actual:
%A

Message:
%s
"))(2)(actual)("Should be equal")); - } -}), Test_testCase("isFalse works", () => { - Expect_isFalse(false)("Should be equal"); -}), Test_testCase("areEqual with msg", () => { - let copyOfStruct_1, arg_6, arg_1_1; - if (!(new Function("try {return this===window;}catch(e){ return false;}"))()) { - assertEqual(2, 3, "They are the same"); - } - else { - throw new Error(contains((copyOfStruct_1 = 2, int32_type), ofArray([int32_type, bool_type, float64_type, string_type, decimal_type, class_type("System.Guid")]), { - Equals: equals, - GetHashCode: structuralHash, - }) ? ((arg_6 = int32ToString(3), (arg_1_1 = int32ToString(2), toText(printf("Expected:
%s

Actual:
%s

Message:
%s
"))(arg_6)(arg_1_1)("They are the same")))) : toText(printf("Expected:
%A

Actual:
%A

Message:
%s
"))(3)(2)("They are the same")); - } -}), Test_testCase("isOk works correctly", () => { - Expect_isOk(new FSharpResult$2(0, [true]), "Should be Ok"); -}), Test_testCase("isOk fails correctly", () => { - Expect_throwsC(() => { - let copyOfStruct_2, arg_7, arg_1_2; - Expect_isOk(new FSharpResult$2(1, ["fails"]), "Should fail"); - if (!(new Function("try {return this===window;}catch(e){ return false;}"))()) { - assertEqual(true, false, "Should not be tested"); - } - else { - throw new Error(contains((copyOfStruct_2 = true, bool_type), ofArray([int32_type, bool_type, float64_type, string_type, decimal_type, class_type("System.Guid")]), { - Equals: equals, - GetHashCode: structuralHash, - }) ? ((arg_7 = toString(false), (arg_1_2 = toString(true), toText(printf("Expected:
%s

Actual:
%s

Message:
%s
"))(arg_7)(arg_1_2)("Should not be tested")))) : toText(printf("Expected:
%A

Actual:
%A

Message:
%s
"))(false)(true)("Should not be tested")); - } - }, (exn) => { - let copyOfStruct_3; - const actual_5 = exn.message; - if ((actual_5 === "Should fail. Expected Ok, was Error(\"fails\").") ? true : !(new Function("try {return this===window;}catch(e){ return false;}"))()) { - assertEqual(actual_5, "Should fail. Expected Ok, was Error(\"fails\").", "Error messages should be the same"); - } - else { - throw new Error(contains((copyOfStruct_3 = actual_5, string_type), ofArray([int32_type, bool_type, float64_type, string_type, decimal_type, class_type("System.Guid")]), { - Equals: equals, - GetHashCode: structuralHash, - }) ? toText(printf("Expected:
%s

Actual:
%s

Message:
%s
"))("Should fail. Expected Ok, was Error(\"fails\").")(actual_5)("Error messages should be the same") : toText(printf("Expected:
%A

Actual:
%A

Message:
%s
"))("Should fail. Expected Ok, was Error(\"fails\").")(actual_5)("Error messages should be the same")); - } - }); -}), Test_testCase("isEmpty works correctly", () => { - Expect_isEmpty([], "Should be empty"); -}), Test_testCase("isEmpty fails correctly", () => { - Expect_throwsC(() => { - let copyOfStruct_4, arg_9, arg_1_4; - Expect_isEmpty([1], "Should fail"); - if (!(new Function("try {return this===window;}catch(e){ return false;}"))()) { - assertEqual(true, false, "Should not be tested"); - } - else { - throw new Error(contains((copyOfStruct_4 = true, bool_type), ofArray([int32_type, bool_type, float64_type, string_type, decimal_type, class_type("System.Guid")]), { - Equals: equals, - GetHashCode: structuralHash, - }) ? ((arg_9 = toString(false), (arg_1_4 = toString(true), toText(printf("Expected:
%s

Actual:
%s

Message:
%s
"))(arg_9)(arg_1_4)("Should not be tested")))) : toText(printf("Expected:
%A

Actual:
%A

Message:
%s
"))(false)(true)("Should not be tested")); - } - }, (exn_1) => { - let copyOfStruct_5; - const actual_9 = exn_1.message; - if ((actual_9 === "Should fail. Should be empty.") ? true : !(new Function("try {return this===window;}catch(e){ return false;}"))()) { - assertEqual(actual_9, "Should fail. Should be empty.", "Error messages should be the same"); - } - else { - throw new Error(contains((copyOfStruct_5 = actual_9, string_type), ofArray([int32_type, bool_type, float64_type, string_type, decimal_type, class_type("System.Guid")]), { - Equals: equals, - GetHashCode: structuralHash, - }) ? toText(printf("Expected:
%s

Actual:
%s

Message:
%s
"))("Should fail. Should be empty.")(actual_9)("Error messages should be the same") : toText(printf("Expected:
%A

Actual:
%A

Message:
%s
"))("Should fail. Should be empty.")(actual_9)("Error messages should be the same")); - } - }); -}), Test_testCase("isNonEmpty works correctly", () => { - Expect_isNonEmpty([1], "Should not be empty"); -}), Test_testCase("isNonEmpty fails correctly", () => { - Expect_throwsC(() => { - let copyOfStruct_6, arg_11, arg_1_6; - Expect_isNonEmpty([], "Should fail"); - if (!(new Function("try {return this===window;}catch(e){ return false;}"))()) { - assertEqual(true, false, "Should not be tested"); - } - else { - throw new Error(contains((copyOfStruct_6 = true, bool_type), ofArray([int32_type, bool_type, float64_type, string_type, decimal_type, class_type("System.Guid")]), { - Equals: equals, - GetHashCode: structuralHash, - }) ? ((arg_11 = toString(false), (arg_1_6 = toString(true), toText(printf("Expected:
%s

Actual:
%s

Message:
%s
"))(arg_11)(arg_1_6)("Should not be tested")))) : toText(printf("Expected:
%A

Actual:
%A

Message:
%s
"))(false)(true)("Should not be tested")); - } - }, (exn_2) => { - let copyOfStruct_7; - const actual_13 = exn_2.message; - if ((actual_13 === "Should fail. Should not be empty.") ? true : !(new Function("try {return this===window;}catch(e){ return false;}"))()) { - assertEqual(actual_13, "Should fail. Should not be empty.", "Error messages should be the same"); - } - else { - throw new Error(contains((copyOfStruct_7 = actual_13, string_type), ofArray([int32_type, bool_type, float64_type, string_type, decimal_type, class_type("System.Guid")]), { - Equals: equals, - GetHashCode: structuralHash, - }) ? toText(printf("Expected:
%s

Actual:
%s

Message:
%s
"))("Should fail. Should not be empty.")(actual_13)("Error messages should be the same") : toText(printf("Expected:
%A

Actual:
%A

Message:
%s
"))("Should fail. Should not be empty.")(actual_13)("Error messages should be the same")); - } - }); -}), Test_testCase("wantOk works correctly", () => { - let copyOfStruct_8, arg_13, arg_1_8; - const actual_15 = Expect_wantOk(new FSharpResult$2(0, [true]), "Should be Ok"); - if ((actual_15 === true) ? true : !(new Function("try {return this===window;}catch(e){ return false;}"))()) { - assertEqual(actual_15, true, "Should be true"); - } - else { - throw new Error(contains((copyOfStruct_8 = actual_15, bool_type), ofArray([int32_type, bool_type, float64_type, string_type, decimal_type, class_type("System.Guid")]), { - Equals: equals, - GetHashCode: structuralHash, - }) ? ((arg_13 = toString(true), (arg_1_8 = toString(actual_15), toText(printf("Expected:
%s

Actual:
%s

Message:
%s
"))(arg_13)(arg_1_8)("Should be true")))) : toText(printf("Expected:
%A

Actual:
%A

Message:
%s
"))(true)(actual_15)("Should be true")); - } -}), Test_testCase("wantOk fails correctly", () => { - Expect_throwsC(() => { - let copyOfStruct_9, arg_14, arg_1_9; - Expect_wantOk(new FSharpResult$2(1, [true]), "Should fail"); - if (!(new Function("try {return this===window;}catch(e){ return false;}"))()) { - assertEqual(true, false, "Should not be tested"); - } - else { - throw new Error(contains((copyOfStruct_9 = true, bool_type), ofArray([int32_type, bool_type, float64_type, string_type, decimal_type, class_type("System.Guid")]), { - Equals: equals, - GetHashCode: structuralHash, - }) ? ((arg_14 = toString(false), (arg_1_9 = toString(true), toText(printf("Expected:
%s

Actual:
%s

Message:
%s
"))(arg_14)(arg_1_9)("Should not be tested")))) : toText(printf("Expected:
%A

Actual:
%A

Message:
%s
"))(false)(true)("Should not be tested")); - } - }, (exn_3) => { - Expect_stringContains(exn_3.message, "Expected Ok", "Error contains the error message"); - }); -}), Test_testCase("isError works correctly", () => { - Expect_isError(new FSharpResult$2(1, ["Is Error"]), "Should be Error"); -}), Test_testCase("isError fails correctly", () => { - Expect_throwsC(() => { - let copyOfStruct_10, arg_15, arg_1_10; - Expect_isError(new FSharpResult$2(0, [true]), "Should fail"); - if (!(new Function("try {return this===window;}catch(e){ return false;}"))()) { - assertEqual(true, false, "Should not be tested"); - } - else { - throw new Error(contains((copyOfStruct_10 = true, bool_type), ofArray([int32_type, bool_type, float64_type, string_type, decimal_type, class_type("System.Guid")]), { - Equals: equals, - GetHashCode: structuralHash, - }) ? ((arg_15 = toString(false), (arg_1_10 = toString(true), toText(printf("Expected:
%s

Actual:
%s

Message:
%s
"))(arg_15)(arg_1_10)("Should not be tested")))) : toText(printf("Expected:
%A

Actual:
%A

Message:
%s
"))(false)(true)("Should not be tested")); - } - }, (exn_4) => { - Expect_stringContains(exn_4.message, "Expected Error", "error message part is present"); - }); -}), Test_testCase("wantError works correctly", () => { - let copyOfStruct_11, arg_16, arg_1_11; - const actual_22 = Expect_wantError(new FSharpResult$2(1, [true]), "Should be Error"); - if ((actual_22 === true) ? true : !(new Function("try {return this===window;}catch(e){ return false;}"))()) { - assertEqual(actual_22, true, "Should be true"); - } - else { - throw new Error(contains((copyOfStruct_11 = actual_22, bool_type), ofArray([int32_type, bool_type, float64_type, string_type, decimal_type, class_type("System.Guid")]), { - Equals: equals, - GetHashCode: structuralHash, - }) ? ((arg_16 = toString(true), (arg_1_11 = toString(actual_22), toText(printf("Expected:
%s

Actual:
%s

Message:
%s
"))(arg_16)(arg_1_11)("Should be true")))) : toText(printf("Expected:
%A

Actual:
%A

Message:
%s
"))(true)(actual_22)("Should be true")); - } -}), Test_testCase("wantError fails correctly", () => { - Expect_throwsC(() => { - let copyOfStruct_12, arg_17, arg_1_12; - Expect_wantError(new FSharpResult$2(0, [true]), "Should fail"); - if (!(new Function("try {return this===window;}catch(e){ return false;}"))()) { - assertEqual(true, false, "Should not be tested"); - } - else { - throw new Error(contains((copyOfStruct_12 = true, bool_type), ofArray([int32_type, bool_type, float64_type, string_type, decimal_type, class_type("System.Guid")]), { - Equals: equals, - GetHashCode: structuralHash, - }) ? ((arg_17 = toString(false), (arg_1_12 = toString(true), toText(printf("Expected:
%s

Actual:
%s

Message:
%s
"))(arg_17)(arg_1_12)("Should not be tested")))) : toText(printf("Expected:
%A

Actual:
%A

Message:
%s
"))(false)(true)("Should not be tested")); - } - }, (exn_5) => { - Expect_stringContains(exn_5.message, "Expected Error", "Error message contains the correct error"); - }); -}), Test_testCase("isSome works correctly", () => { - Expect_isSome(true, "Should be Some"); -}), Test_testCase("isSome fails correctly", () => { - Expect_throwsC(() => { - let copyOfStruct_13, arg_18, arg_1_13; - Expect_isSome(void 0, "Should fail"); - if (!(new Function("try {return this===window;}catch(e){ return false;}"))()) { - assertEqual(true, false, "Should not be tested"); - } - else { - throw new Error(contains((copyOfStruct_13 = true, bool_type), ofArray([int32_type, bool_type, float64_type, string_type, decimal_type, class_type("System.Guid")]), { - Equals: equals, - GetHashCode: structuralHash, - }) ? ((arg_18 = toString(false), (arg_1_13 = toString(true), toText(printf("Expected:
%s

Actual:
%s

Message:
%s
"))(arg_18)(arg_1_13)("Should not be tested")))) : toText(printf("Expected:
%A

Actual:
%A

Message:
%s
"))(false)(true)("Should not be tested")); - } - }, (exn_6) => { - let copyOfStruct_14; - const actual_28 = exn_6.message; - if ((actual_28 === "Should fail. Expected Some _, was None.") ? true : !(new Function("try {return this===window;}catch(e){ return false;}"))()) { - assertEqual(actual_28, "Should fail. Expected Some _, was None.", "Error messages should be the same"); - } - else { - throw new Error(contains((copyOfStruct_14 = actual_28, string_type), ofArray([int32_type, bool_type, float64_type, string_type, decimal_type, class_type("System.Guid")]), { - Equals: equals, - GetHashCode: structuralHash, - }) ? toText(printf("Expected:
%s

Actual:
%s

Message:
%s
"))("Should fail. Expected Some _, was None.")(actual_28)("Error messages should be the same") : toText(printf("Expected:
%A

Actual:
%A

Message:
%s
"))("Should fail. Expected Some _, was None.")(actual_28)("Error messages should be the same")); - } - }); -}), Test_testCase("wantSome works correctly", () => { - let copyOfStruct_15, arg_20, arg_1_15; - const actual_30 = Expect_wantSome(true, "Should be Some"); - if ((actual_30 === true) ? true : !(new Function("try {return this===window;}catch(e){ return false;}"))()) { - assertEqual(actual_30, true, "Should be true"); - } - else { - throw new Error(contains((copyOfStruct_15 = actual_30, bool_type), ofArray([int32_type, bool_type, float64_type, string_type, decimal_type, class_type("System.Guid")]), { - Equals: equals, - GetHashCode: structuralHash, - }) ? ((arg_20 = toString(true), (arg_1_15 = toString(actual_30), toText(printf("Expected:
%s

Actual:
%s

Message:
%s
"))(arg_20)(arg_1_15)("Should be true")))) : toText(printf("Expected:
%A

Actual:
%A

Message:
%s
"))(true)(actual_30)("Should be true")); - } -}), Test_testCase("wantSome fails correctly", () => { - Expect_throwsC(() => { - let copyOfStruct_16, arg_21, arg_1_16; - Expect_isSome(void 0, "Should fail"); - if (!(new Function("try {return this===window;}catch(e){ return false;}"))()) { - assertEqual(true, false, "Should not be tested"); - } - else { - throw new Error(contains((copyOfStruct_16 = true, bool_type), ofArray([int32_type, bool_type, float64_type, string_type, decimal_type, class_type("System.Guid")]), { - Equals: equals, - GetHashCode: structuralHash, - }) ? ((arg_21 = toString(false), (arg_1_16 = toString(true), toText(printf("Expected:
%s

Actual:
%s

Message:
%s
"))(arg_21)(arg_1_16)("Should not be tested")))) : toText(printf("Expected:
%A

Actual:
%A

Message:
%s
"))(false)(true)("Should not be tested")); - } - }, (exn_7) => { - let copyOfStruct_17; - const actual_33 = exn_7.message; - if ((actual_33 === "Should fail. Expected Some _, was None.") ? true : !(new Function("try {return this===window;}catch(e){ return false;}"))()) { - assertEqual(actual_33, "Should fail. Expected Some _, was None.", "Error messages should be the same"); - } - else { - throw new Error(contains((copyOfStruct_17 = actual_33, string_type), ofArray([int32_type, bool_type, float64_type, string_type, decimal_type, class_type("System.Guid")]), { - Equals: equals, - GetHashCode: structuralHash, - }) ? toText(printf("Expected:
%s

Actual:
%s

Message:
%s
"))("Should fail. Expected Some _, was None.")(actual_33)("Error messages should be the same") : toText(printf("Expected:
%A

Actual:
%A

Message:
%s
"))("Should fail. Expected Some _, was None.")(actual_33)("Error messages should be the same")); - } - }); -}), Test_testCase("isNone works correctly", () => { - Expect_isNone(void 0, "Should be Some"); -}), Test_testCase("isNone fails correctly", () => { - Expect_throwsC(() => { - let copyOfStruct_18, arg_23, arg_1_18; - Expect_isNone(true, "Should fail"); - if (!(new Function("try {return this===window;}catch(e){ return false;}"))()) { - assertEqual(true, false, "Should not be tested"); - } - else { - throw new Error(contains((copyOfStruct_18 = true, bool_type), ofArray([int32_type, bool_type, float64_type, string_type, decimal_type, class_type("System.Guid")]), { - Equals: equals, - GetHashCode: structuralHash, - }) ? ((arg_23 = toString(false), (arg_1_18 = toString(true), toText(printf("Expected:
%s

Actual:
%s

Message:
%s
"))(arg_23)(arg_1_18)("Should not be tested")))) : toText(printf("Expected:
%A

Actual:
%A

Message:
%s
"))(false)(true)("Should not be tested")); - } - }, (exn_8) => { - let copyOfStruct_19; - const actual_37 = exn_8.message; - if ((actual_37 === "Should fail. Expected None, was Some(true).") ? true : !(new Function("try {return this===window;}catch(e){ return false;}"))()) { - assertEqual(actual_37, "Should fail. Expected None, was Some(true).", "Error messages should be the same"); - } - else { - throw new Error(contains((copyOfStruct_19 = actual_37, string_type), ofArray([int32_type, bool_type, float64_type, string_type, decimal_type, class_type("System.Guid")]), { - Equals: equals, - GetHashCode: structuralHash, - }) ? toText(printf("Expected:
%s

Actual:
%s

Message:
%s
"))("Should fail. Expected None, was Some(true).")(actual_37)("Error messages should be the same") : toText(printf("Expected:
%A

Actual:
%A

Message:
%s
"))("Should fail. Expected None, was Some(true).")(actual_37)("Error messages should be the same")); - } - }); -}), Test_testCase("isNotNull works correctly", () => { - Expect_isNotNull("not null")("Should not be null"); -}), Test_testCase("isNull works correctly", () => { - Expect_isNull(defaultOf())("Should not be null"); -}), Test_testCase("isNotNaN works correctly", () => { - Expect_isNotNaN(20.4, "Should not be nan"); -}), Test_testCase("isNotNaN fails correctly", () => { - Expect_throws(() => { - Expect_isNotNaN(Number.NaN, "Should fail"); - }, "Should have failed"); -}), Test_testCase("floatClose works correctly", () => { - Expect_floatClose(AccuracyModule_low, 0.1, 0.1, "Should be close enough"); -}), Test_testCase("floatClose fails correctly", () => { - Expect_throws(() => { - Expect_floatClose(AccuracyModule_low, 0.1, 2, "Should be far enough apart"); - }, "Should have failed"); -}), Test_testCase("floatLessThanOrClose works correctly", () => { - Expect_floatLessThanOrClose(AccuracyModule_low, 0.1, 0.1, "Should be close enough"); -}), Test_testCase("floatLessThanOrClose fails correctly", () => { - Expect_throws(() => { - Expect_floatLessThanOrClose(AccuracyModule_low, 2, 1, "Should be far enough apart"); - }, "Should have failed"); -}), Test_testCase("floatGreaterThanOrClose works correctly", () => { - Expect_floatGreaterThanOrClose(AccuracyModule_low, 0.123, 0.123, "Should be close enough"); -}), Test_testCase("floatGreaterThanOrClose fails correctly", () => { - Expect_throws(() => { - Expect_floatGreaterThanOrClose(AccuracyModule_low, 1, 2, "Should be far enough apart"); - }, "Should have failed"); -}), Test_testCase("failwith fails correctly", () => { - Expect_throwsC(() => { - throw new Error("Should fail"); - }, (exn_9) => { - let copyOfStruct_20; - const actual_42 = exn_9.message; - if ((actual_42 === "Should fail") ? true : !(new Function("try {return this===window;}catch(e){ return false;}"))()) { - assertEqual(actual_42, "Should fail", "Error messages should be the same"); - } - else { - throw new Error(contains((copyOfStruct_20 = actual_42, string_type), ofArray([int32_type, bool_type, float64_type, string_type, decimal_type, class_type("System.Guid")]), { - Equals: equals, - GetHashCode: structuralHash, - }) ? toText(printf("Expected:
%s

Actual:
%s

Message:
%s
"))("Should fail")(actual_42)("Error messages should be the same") : toText(printf("Expected:
%A

Actual:
%A

Message:
%s
"))("Should fail")(actual_42)("Error messages should be the same")); - } - }); -}), Test_testCase("failwithf fails correctly", () => { - Expect_throwsC(() => { - toFail(printf("%s%s"))("Should fail")("!"); - }, (exn_10) => { - let copyOfStruct_21; - const actual_43 = exn_10.message; - if ((actual_43 === "Should fail!") ? true : !(new Function("try {return this===window;}catch(e){ return false;}"))()) { - assertEqual(actual_43, "Should fail!", "Error messages should be the same"); - } - else { - throw new Error(contains((copyOfStruct_21 = actual_43, string_type), ofArray([int32_type, bool_type, float64_type, string_type, decimal_type, class_type("System.Guid")]), { - Equals: equals, - GetHashCode: structuralHash, - }) ? toText(printf("Expected:
%s

Actual:
%s

Message:
%s
"))("Should fail!")(actual_43)("Error messages should be the same") : toText(printf("Expected:
%A

Actual:
%A

Message:
%s
"))("Should fail!")(actual_43)("Error messages should be the same")); - } - }); -}), Test_testCase("isNotInfinity works correctly", () => { - Expect_isNotInfinity(20.4, "Shouldn\'t be infinity"); -}), Test_testCase("isNotInfinity fails correctly", () => { - Expect_throws(() => { - Expect_isNotInfinity(Number.POSITIVE_INFINITY, "Should fail"); - }, "Should have failed"); -}), Test_testCaseAsync("testCaseAsync works", singleton.Delay(() => singleton.Bind(sleep(3000), () => singleton.Bind(singleton.Delay(() => singleton.Return(21)), (_arg_34) => { - let copyOfStruct_22, arg_29, arg_1_22; - const actual_46 = (_arg_34 * 2) | 0; - if ((actual_46 === 42) ? true : !(new Function("try {return this===window;}catch(e){ return false;}"))()) { - assertEqual(actual_46, 42, "Should be equal"); - } - else { - throw new Error(contains((copyOfStruct_22 = actual_46, int32_type), ofArray([int32_type, bool_type, float64_type, string_type, decimal_type, class_type("System.Guid")]), { - Equals: equals, - GetHashCode: structuralHash, - }) ? ((arg_29 = int32ToString(42), (arg_1_22 = int32ToString(actual_46), toText(printf("Expected:
%s

Actual:
%s

Message:
%s
"))(arg_29)(arg_1_22)("Should be equal")))) : toText(printf("Expected:
%A

Actual:
%A

Message:
%s
"))(42)(actual_46)("Should be equal")); - } - return singleton.Zero(); -})))), Test_ptestCase("skipping this one", () => { - throw new Error("Shouldn\'t be running this test"); -}), Test_ptestCaseAsync("skipping this one async", singleton.Delay(() => { - throw new Error("Shouldn\'t be running this test"); - return singleton.Zero(); -})), Test_testCase("stringContains works correctly", () => { - Expect_stringContains("Hello, World!", "World", "Should contain string"); -}), Test_testCase("stringContains fails correctly", () => { - let copyOfStruct_24, copyOfStruct_23, arg_30, arg_1_23; - try { - Expect_stringContains("Hello, Mocha!", "World", "Should fail"); - if (!(new Function("try {return this===window;}catch(e){ return false;}"))()) { - assertEqual(true, false, "Should not be tested"); - } - else { - throw new Error(contains((copyOfStruct_23 = true, bool_type), ofArray([int32_type, bool_type, float64_type, string_type, decimal_type, class_type("System.Guid")]), { - Equals: equals, - GetHashCode: structuralHash, - }) ? ((arg_30 = toString(false), (arg_1_23 = toString(true), toText(printf("Expected:
%s

Actual:
%s

Message:
%s
"))(arg_30)(arg_1_23)("Should not be tested")))) : toText(printf("Expected:
%A

Actual:
%A

Message:
%s
"))(false)(true)("Should not be tested")); - } - } - catch (ex) { - const actual_48 = ex.message; - if ((actual_48 === "Should fail. Expected subject string \'Hello, Mocha!\' to contain substring \'World\'.") ? true : !(new Function("try {return this===window;}catch(e){ return false;}"))()) { - assertEqual(actual_48, "Should fail. Expected subject string \'Hello, Mocha!\' to contain substring \'World\'.", "Error messages should be the same"); - } - else { - throw new Error(contains((copyOfStruct_24 = actual_48, string_type), ofArray([int32_type, bool_type, float64_type, string_type, decimal_type, class_type("System.Guid")]), { - Equals: equals, - GetHashCode: structuralHash, - }) ? toText(printf("Expected:
%s

Actual:
%s

Message:
%s
"))("Should fail. Expected subject string \'Hello, Mocha!\' to contain substring \'World\'.")(actual_48)("Error messages should be the same") : toText(printf("Expected:
%A

Actual:
%A

Message:
%s
"))("Should fail. Expected subject string \'Hello, Mocha!\' to contain substring \'World\'.")(actual_48)("Error messages should be the same")); - } - } -}), Test_testList("containsAll", ofArray([(() => { - const builder$0040_3 = Test_TestCaseBuilder_$ctor_Z7EF1EC3F("identical sequence", new FocusState(0, [])); - return Test_TestCaseBuilder__Run_3A5B6456(builder$0040_3, Test_TestCaseBuilder__Delay_1505(builder$0040_3, () => { - Expect_containsAll([21, 37], [21, 37], "Identical sequences"); - Test_TestCaseBuilder__Zero(builder$0040_3); - })); -})(), (() => { - const builder$0040_4 = Test_TestCaseBuilder_$ctor_Z7EF1EC3F("sequence contains all in different order", new FocusState(0, [])); - return Test_TestCaseBuilder__Run_3A5B6456(builder$0040_4, Test_TestCaseBuilder__Delay_1505(builder$0040_4, () => { - Expect_containsAll([21, 37], [37, 21], "Same elements in different order"); - Test_TestCaseBuilder__Zero(builder$0040_4); - })); -})()]))])); - -export const secondModuleTests = Test_testList("second Module tests", singleton_1(Test_testCase("module works properly", () => { - let copyOfStruct, arg, arg_1; - const actual = 31415 / 10000; - if ((actual === 3.1415) ? true : !(new Function("try {return this===window;}catch(e){ return false;}"))()) { - assertEqual(actual, 3.1415, "Should be equal"); - } - else { - throw new Error(contains((copyOfStruct = actual, float64_type), ofArray([int32_type, bool_type, float64_type, string_type, decimal_type, class_type("System.Guid")]), { - Equals: equals, - GetHashCode: structuralHash, - }) ? ((arg = (3.1415).toString(), (arg_1 = actual.toString(), toText(printf("Expected:
%s

Actual:
%s

Message:
%s
"))(arg)(arg_1)("Should be equal")))) : toText(printf("Expected:
%A

Actual:
%A

Message:
%s
"))(3.1415)(actual)("Should be equal")); - } -}))); - -export const structuralEqualityTests = Test_testList("testing records", ofArray([Test_testCase("they are equal", () => { - let copyOfStruct, arg, arg_1; - const actual_1 = { - one: "one", - two: 2, - }; - const expected_1 = { - one: "one", - two: 2, - }; - if (equals_1(actual_1, expected_1) ? true : !(new Function("try {return this===window;}catch(e){ return false;}"))()) { - assertEqual(actual_1, expected_1, "Should be equal"); - } - else { - throw new Error(contains((copyOfStruct = actual_1, anonRecord_type(["one", string_type], ["two", int32_type])), ofArray([int32_type, bool_type, float64_type, string_type, decimal_type, class_type("System.Guid")]), { - Equals: equals, - GetHashCode: structuralHash, - }) ? ((arg = toString(expected_1), (arg_1 = toString(actual_1), toText(printf("Expected:
%s

Actual:
%s

Message:
%s
"))(arg)(arg_1)("Should be equal")))) : toText(printf("Expected:
%A

Actual:
%A

Message:
%s
"))(expected_1)(actual_1)("Should be equal")); - } -}), Test_testCase("they are not equal", () => { - Expect_notEqual({ - one: "one", - two: 2, - }, { - one: "one", - two: 1, - }, "Should be equal"); -})])); - -export const nestedTestCase = Test_testList("Nested", singleton_1(Test_testList("Nested even more", singleton_1(Test_testCase("Nested test case", () => { - Expect_isTrue(true)("Should be true"); -}))))); - -export const focusedTestsCases = Test_testList("Focused", ofArray([Test_ftestCase("Focused sync test", () => { - let copyOfStruct, arg, arg_1; - const actual = 2; - if ((actual === 2) ? true : !(new Function("try {return this===window;}catch(e){ return false;}"))()) { - assertEqual(actual, 2, "Should be equal"); - } - else { - throw new Error(contains((copyOfStruct = actual, int32_type), ofArray([int32_type, bool_type, float64_type, string_type, decimal_type, class_type("System.Guid")]), { - Equals: equals, - GetHashCode: structuralHash, - }) ? ((arg = int32ToString(2), (arg_1 = int32ToString(actual), toText(printf("Expected:
%s

Actual:
%s

Message:
%s
"))(arg)(arg_1)("Should be equal")))) : toText(printf("Expected:
%A

Actual:
%A

Message:
%s
"))(2)(actual)("Should be equal")); - } -}), Test_ftestCaseAsync("Focused async test", singleton.Delay(() => { - let copyOfStruct_1, arg_6, arg_1_1; - const actual_1 = 2; - if ((actual_1 === 2) ? true : !(new Function("try {return this===window;}catch(e){ return false;}"))()) { - assertEqual(actual_1, 2, "Should be equal"); - } - else { - throw new Error(contains((copyOfStruct_1 = actual_1, int32_type), ofArray([int32_type, bool_type, float64_type, string_type, decimal_type, class_type("System.Guid")]), { - Equals: equals, - GetHashCode: structuralHash, - }) ? ((arg_6 = int32ToString(2), (arg_1_1 = int32ToString(actual_1), toText(printf("Expected:
%s

Actual:
%s

Message:
%s
"))(arg_6)(arg_1_1)("Should be equal")))) : toText(printf("Expected:
%A

Actual:
%A

Message:
%s
"))(2)(actual_1)("Should be equal")); - } - return singleton.Zero(); -}))])); - -export const all = Test_testList("All", ofArray([tests_sequential, tests_basic, secondModuleTests, structuralEqualityTests, nestedTestCase])); - -(function (argv) { - return Mocha_runTests(all); -})(typeof process === 'object' ? process.argv.slice(2) : []); - diff --git a/tests/js/src/Pyxpecto.js b/tests/js/src/Pyxpecto.js deleted file mode 100644 index 3aa05a1..0000000 --- a/tests/js/src/Pyxpecto.js +++ /dev/null @@ -1,989 +0,0 @@ -import { toString, Record, Union } from "../fable_modules/fable-library.4.1.4/Types.js"; -import { record_type, float64_type, list_type, class_type, lambda_type, unit_type, string_type, union_type } from "../fable_modules/fable-library.4.1.4/Reflection.js"; -import { iterate, collect as collect_1, exists as exists_1, isEmpty as isEmpty_1, contains, filter, ofSeq, singleton } from "../fable_modules/fable-library.4.1.4/List.js"; -import { Operators_Using } from "../fable_modules/fable-library.4.1.4/FSharp.Core.js"; -import { curry2, stringHash, structuralHash, assertEqual, defaultOf, equals, assertNotEqual, disposeSafe, getEnumerator } from "../fable_modules/fable-library.4.1.4/Util.js"; -import { singleton as singleton_1 } from "../fable_modules/fable-library.4.1.4/AsyncBuilder.js"; -import { toConsole, isNullOrWhiteSpace, toText, printf, toFail } from "../fable_modules/fable-library.4.1.4/String.js"; -import { max, isInfinity } from "../fable_modules/fable-library.4.1.4/Double.js"; -import { collect, delay, toList, length, forAll, exists, isEmpty } from "../fable_modules/fable-library.4.1.4/Seq.js"; -import { value as value_2 } from "../fable_modules/fable-library.4.1.4/Option.js"; -import * as sys from "sys"; -import { runSynchronously } from "../fable_modules/fable-library.4.1.4/Async.js"; -import { contains as contains_1 } from "../fable_modules/fable-library.4.1.4/Array.js"; -import { StringBuilder_$ctor, StringBuilder__AppendLine_Z721C83C5 } from "../fable_modules/fable-library.4.1.4/System.Text.js"; - -export class FocusState extends Union { - constructor(tag, fields) { - super(); - this.tag = tag; - this.fields = fields; - } - cases() { - return ["Normal", "Pending", "Focused"]; - } -} - -export function FocusState_$reflection() { - return union_type("Fable.Pyxpecto.FocusState", [], FocusState, () => [[], [], []]); -} - -export class TestCase extends Union { - constructor(tag, fields) { - super(); - this.tag = tag; - this.fields = fields; - } - cases() { - return ["SyncTest", "AsyncTest", "TestList", "TestListSequential"]; - } -} - -export function TestCase_$reflection() { - return union_type("Fable.Pyxpecto.TestCase", [], TestCase, () => [[["Item1", string_type], ["Item2", lambda_type(unit_type, unit_type)], ["Item3", FocusState_$reflection()]], [["Item1", string_type], ["Item2", class_type("Microsoft.FSharp.Control.FSharpAsync`1", [unit_type])], ["Item3", FocusState_$reflection()]], [["Item1", string_type], ["Item2", list_type(TestCase_$reflection())]], [["Item1", string_type], ["Item2", list_type(TestCase_$reflection())]]]); -} - -export class Accuracy extends Record { - constructor(absolute, relative) { - super(); - this.absolute = absolute; - this.relative = relative; - } -} - -export function Accuracy_$reflection() { - return record_type("Fable.Pyxpecto.Accuracy", [], Accuracy, () => [["absolute", float64_type], ["relative", float64_type]]); -} - -export const AccuracyModule_low = new Accuracy(1E-06, 0.001); - -export const AccuracyModule_medium = new Accuracy(1E-08, 1E-05); - -export const AccuracyModule_high = new Accuracy(1E-10, 1E-07); - -export const AccuracyModule_veryHigh = new Accuracy(1E-12, 1E-09); - -export function Test_testCase(name, body) { - return new TestCase(0, [name, body, new FocusState(0, [])]); -} - -export function Test_ptestCase(name, body) { - return new TestCase(0, [name, body, new FocusState(1, [])]); -} - -export function Test_ftestCase(name, body) { - return new TestCase(0, [name, body, new FocusState(2, [])]); -} - -export function Test_testCaseAsync(name, body) { - return new TestCase(1, [name, body, new FocusState(0, [])]); -} - -export function Test_ptestCaseAsync(name, body) { - return new TestCase(1, [name, body, new FocusState(1, [])]); -} - -export function Test_ftestCaseAsync(name, body) { - return new TestCase(1, [name, body, new FocusState(2, [])]); -} - -export function Test_testList(name, tests) { - return new TestCase(2, [name, tests]); -} - -export function Test_testSequenced(test) { - switch (test.tag) { - case 1: { - const name_1 = test.fields[0]; - return new TestCase(3, [name_1, singleton(new TestCase(1, [name_1, test.fields[1], test.fields[2]]))]); - } - case 2: - return new TestCase(3, [test.fields[0], test.fields[1]]); - case 3: - return new TestCase(3, [test.fields[0], test.fields[1]]); - default: { - const name = test.fields[0]; - return new TestCase(3, [name, singleton(new TestCase(0, [name, test.fields[1], test.fields[2]]))]); - } - } -} - -export class Test_TestCaseBuilder { - constructor(name, focusState) { - this.name = name; - this.focusState = focusState; - } -} - -export function Test_TestCaseBuilder_$reflection() { - return class_type("Fable.Pyxpecto.Test.TestCaseBuilder", void 0, Test_TestCaseBuilder); -} - -export function Test_TestCaseBuilder_$ctor_Z69FFBD2B(name, focusState) { - return new Test_TestCaseBuilder(name, focusState); -} - -export function Test_TestCaseBuilder__Zero(_) { -} - -export function Test_TestCaseBuilder__Delay_1505(_, fn) { - return fn; -} - -export function Test_TestCaseBuilder__Using_Z3647408D(_, disposable, fn) { - return Operators_Using(disposable, fn); -} - -export function Test_TestCaseBuilder__While_Z4F211AEA(_, condition, fn) { - while (condition()) { - fn(); - } -} - -export function Test_TestCaseBuilder__For_Z371464DD(_, sequence, fn) { - const enumerator = getEnumerator(sequence); - try { - while (enumerator["System.Collections.IEnumerator.MoveNext"]()) { - fn(enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]()); - } - } - finally { - disposeSafe(enumerator); - } -} - -export function Test_TestCaseBuilder__Combine_3A59D1F3(_, fn1, fn2) { - fn2(); - return fn1; -} - -export function Test_TestCaseBuilder__TryFinally_33907399(_, fn, compensation) { - try { - return fn(); - } - finally { - compensation(); - } -} - -export function Test_TestCaseBuilder__TryWith_Z570AC55B(_, fn, catchHandler) { - try { - return fn(); - } - catch (e) { - return catchHandler(e); - } -} - -export function Test_TestCaseBuilder__Run_3A5B6456(_, fn) { - return new TestCase(0, [_.name, fn, _.focusState]); -} - -export class Test_TestAsyncBuilder { - constructor(name, focusState) { - this.name = name; - this.focusState = focusState; - } -} - -export function Test_TestAsyncBuilder_$reflection() { - return class_type("Fable.Pyxpecto.Test.TestAsyncBuilder", void 0, Test_TestAsyncBuilder); -} - -export function Test_TestAsyncBuilder_$ctor_Z69FFBD2B(name, focusState) { - return new Test_TestAsyncBuilder(name, focusState); -} - -export function Test_TestAsyncBuilder__Zero(_) { - return singleton_1.Zero(); -} - -export function Test_TestAsyncBuilder__Delay_Z5276B41B(_, fn) { - return singleton_1.Delay(fn); -} - -export function Test_TestAsyncBuilder__Return_1505(_, x) { - return singleton_1.Return(x); -} - -export function Test_TestAsyncBuilder__ReturnFrom_ZD4A93B1(_, x) { - return singleton_1.ReturnFrom(x); -} - -export function Test_TestAsyncBuilder__Bind_7A510B33(_, computation, fn) { - return singleton_1.Bind(computation, fn); -} - -export function Test_TestAsyncBuilder__Using_14BA44F9(_, disposable, fn) { - return singleton_1.Using(disposable, fn); -} - -export function Test_TestAsyncBuilder__While_49259930(_, condition, fn) { - return singleton_1.While(condition, fn); -} - -export function Test_TestAsyncBuilder__For_Z23956591(_, sequence, fn) { - return singleton_1.For(sequence, fn); -} - -export function Test_TestAsyncBuilder__Combine_Z3AE9B5C1(_, fn1, fn2) { - return singleton_1.Combine(fn1, fn2); -} - -export function Test_TestAsyncBuilder__TryFinally_73399279(_, fn, compensation) { - return singleton_1.TryFinally(fn, compensation); -} - -export function Test_TestAsyncBuilder__TryWith_48476DCF(_, fn, catchHandler) { - return singleton_1.TryWith(fn, catchHandler); -} - -export function Test_TestAsyncBuilder__Run_Z3C5FE790(_, fn) { - return new TestCase(1, [_.name, fn, _.focusState]); -} - -export function Test_failtest(msg) { - throw new Error(msg); -} - -export function Test_failtestf(fmt, msg) { - return toFail(fmt)(msg); -} - -export function Expect_notEqual(actual, expected, msg) { - assertNotEqual(actual, expected, msg); -} - -function Expect_isNull$0027(cond) { - if (equals(cond, defaultOf())) { - return true; - } - else { - return false; - } -} - -export function Expect_isNull(cond) { - const actual = Expect_isNull$0027(cond); - return (msg) => { - const actual_1 = actual; - const msg_1 = msg; - if (actual_1 === true) { - assertEqual(actual_1, true, msg_1); - } - else { - throw new Error(` Expected: ${'\033[96m'}${true}${'\033[0m'} - Actual: ${'\033[91m'}${actual_1}${'\033[0m'} - Message: ${msg_1}`); - } - }; -} - -export function Expect_isNotNull(cond) { - const actual = Expect_isNull$0027(cond); - return (msg) => { - Expect_notEqual(actual, true, msg); - }; -} - -export function Expect_isNotNaN(cond, msg) { - if (Number.isNaN(cond)) { - throw new Error(msg); - } -} - -export function Expect_isNotInfinity(cond, msg) { - if (isInfinity(cond)) { - throw new Error(msg); - } -} - -export function Expect_isTrue(cond) { - return (msg) => { - const actual = cond; - const msg_1 = msg; - if (actual === true) { - assertEqual(actual, true, msg_1); - } - else { - throw new Error(` Expected: ${'\033[96m'}${true}${'\033[0m'} - Actual: ${'\033[91m'}${actual}${'\033[0m'} - Message: ${msg_1}`); - } - }; -} - -export function Expect_isFalse(cond) { - return (msg) => { - const actual = cond; - const msg_1 = msg; - if (actual === false) { - assertEqual(actual, false, msg_1); - } - else { - throw new Error(` Expected: ${'\033[96m'}${false}${'\033[0m'} - Actual: ${'\033[91m'}${actual}${'\033[0m'} - Message: ${msg_1}`); - } - }; -} - -export function Expect_isZero(cond) { - return (msg) => { - const actual = cond | 0; - const msg_1 = msg; - if (actual === 0) { - assertEqual(actual, 0, msg_1); - } - else { - throw new Error(` Expected: ${'\033[96m'}${0}${'\033[0m'} - Actual: ${'\033[91m'}${actual}${'\033[0m'} - Message: ${msg_1}`); - } - }; -} - -export function Expect_isEmpty(x, msg) { - if (!isEmpty(x)) { - toFail(printf("%s. Should be empty."))(msg); - } -} - -export function Expect_pass() { - assertEqual(true, true, "The test passed"); -} - -export function Expect_passWithMsg(message) { - const msg = message; - assertEqual(true, true, msg); -} - -export function Expect_exists(x, a, msg) { - if (!exists(a, x)) { - throw new Error(msg); - } -} - -export function Expect_all(x, a, msg) { - if (!forAll(a, x)) { - throw new Error(msg); - } -} - -/** - * Expect the passed sequence not to be empty. - */ -export function Expect_isNonEmpty(x, msg) { - if (isEmpty(x)) { - toFail(printf("%s. Should not be empty."))(msg); - } -} - -/** - * Expects x to be not null nor empty - */ -export function Expect_isNotEmpty(x, msg) { - Expect_isNotNull(x)(msg); - Expect_isNonEmpty(x, msg); -} - -/** - * Expects x to be a sequence of length `number` - */ -export function Expect_hasLength(x, number, msg) { - const actual = length(x) | 0; - const expected = number | 0; - const msg_1 = toText(printf("%s. Expected %A to have length %i"))(msg)(x)(number); - if (actual === expected) { - assertEqual(actual, expected, msg_1); - } - else { - throw new Error(` Expected: ${'\033[96m'}${expected}${'\033[0m'} - Actual: ${'\033[91m'}${actual}${'\033[0m'} - Message: ${msg_1}`); - } -} - -/** - * Expects x to be Result.Ok - */ -export function Expect_isOk(x, message) { - if (x.tag === 1) { - toFail(printf("%s. Expected Ok, was Error(\"%A\")."))(message)(x.fields[0]); - } - else { - Expect_passWithMsg(message); - } -} - -/** - * Expects the value to be a Result.Ok value and returns it or fails the test - */ -export function Expect_wantOk(x, message) { - if (x.tag === 1) { - return toFail(printf("%s. Expected Ok, was Error(\"%A\")."))(message)(x.fields[0]); - } - else { - Expect_passWithMsg(message); - return x.fields[0]; - } -} - -export function Expect_stringContains(subject, substring, message) { - if (!(subject.indexOf(substring) >= 0)) { - toFail(printf("%s. Expected subject string \'%s\' to contain substring \'%s\'."))(message)(subject)(substring); - } - else { - Expect_passWithMsg(message); - } -} - -/** - * Expects x to be Result.Error - */ -export function Expect_isError(x, message) { - if (x.tag === 0) { - toFail(printf("%s. Expected Error _, was Ok(%A)."))(message)(x.fields[0]); - } - else { - Expect_passWithMsg(message); - } -} - -export function Expect_isSome(x, message) { - if (x == null) { - toFail(printf("%s. Expected Some _, was None."))(message); - } - else { - Expect_passWithMsg(message); - } -} - -/** - * Expects the value to be a Some x value and returns x or fails the test - */ -export function Expect_wantSome(x, message) { - if (x == null) { - return toFail(printf("%s. Expected Some _, was None."))(message); - } - else { - const x$0027 = value_2(x); - Expect_passWithMsg(message); - return x$0027; - } -} - -/** - * Expects the value to be a Result.Error value and returns it or fails the test - */ -export function Expect_wantError(x, message) { - if (x.tag === 0) { - return toFail(printf("%s. Expected Error _, was Ok(%A)."))(message)(x.fields[0]); - } - else { - Expect_passWithMsg(message); - return x.fields[0]; - } -} - -export function Expect_isNone(x, message) { - if (x != null) { - const x$0027 = value_2(x); - toFail(printf("%s. Expected None, was Some(%A)."))(message)(x$0027); - } - else { - Expect_passWithMsg(message); - } -} - -function Expect_throws$0027(f) { - try { - f(); - return void 0; - } - catch (exn) { - return exn; - } -} - -/** - * Expects the passed function to throw an exception - */ -export function Expect_throws(f, msg) { - const matchValue = Expect_throws$0027(f); - if (matchValue != null) { - } - else { - toFail(printf("%s. Expected f to throw."))(msg); - } -} - -/** - * Expects the passed function to throw, then calls `cont` with the exception - */ -export function Expect_throwsC(f, cont) { - const matchValue = Expect_throws$0027(f); - if (matchValue != null) { - return cont(matchValue); - } - else { - return toFail(printf("Expected f to throw.")); - } -} - -/** - * Expects the `actual` sequence to contain all elements from `expected` - * It doesn't take into account the number of occurrences and the order of elements. - * Calling this function will enumerate both sequences; they have to be finite. - */ -export function Expect_containsAll(actual, expected, message) { - const matchValue = ofSeq(actual); - const expectedEls = ofSeq(expected); - const actualEls = matchValue; - const matchingEls = filter((a) => contains(a, expectedEls, { - Equals: equals, - GetHashCode: structuralHash, - }), actualEls); - const extraEls = filter((a_1) => !contains(a_1, matchingEls, { - Equals: equals, - GetHashCode: structuralHash, - }), actualEls); - const missingEls = filter((e) => !contains(e, matchingEls, { - Equals: equals, - GetHashCode: structuralHash, - }), expectedEls); - if (isEmpty_1(missingEls)) { - } - else { - Test_failtest(toText(printf("%s. Sequence `actual` does not contain all `expected` elements. Missing elements from `actual`: %A. Extra elements in `actual`: %A"))(message)(missingEls)(extraEls)); - } -} - -/** - * Expects `actual` and `expected` (that are both floats) to be within a - * given `accuracy`. - */ -export function Expect_floatClose(accuracy, actual, expected, message) { - let a, b, m_1; - if (isInfinity(actual)) { - Test_failtestf(printf("%s. Expected actual to not be infinity, but it was."), message); - } - else if (isInfinity(expected)) { - Test_failtestf(printf("%s. Expected expected to not be infinity, but it was."), message); - } - else if (!((a = actual, (b = expected, Math.abs(a - b) <= ((m_1 = accuracy, m_1.absolute + (m_1.relative * max(Math.abs(a), Math.abs(b))))))))) { - let arg; - const m_2 = accuracy; - arg = (m_2.absolute + (m_2.relative * max(Math.abs(actual), Math.abs(expected)))); - const arg_3 = Math.abs(actual - expected); - Test_failtestf(printf("%s. Expected difference to be less than %.20g for accuracy {absolute=%.20g; relative=%.20g}, but was %.20g. actual=%.20g expected=%.20g"), message)(arg)(accuracy.absolute)(accuracy.relative)(arg_3)(actual)(expected); - } -} - -/** - * Expects `actual` to be less than `expected` or to be within a - * given `accuracy`. - */ -export function Expect_floatLessThanOrClose(accuracy, actual, expected, message) { - if (actual > expected) { - Expect_floatClose(accuracy, actual, expected, message); - } -} - -/** - * Expects `actual` to be greater than `expected` or to be within a - * given `accuracy`. - */ -export function Expect_floatGreaterThanOrClose(accuracy, actual, expected, message) { - if (actual < expected) { - Expect_floatClose(accuracy, actual, expected, message); - } -} - -export function Pyxpecto_isFocused(test) { - let matchResult, tests, tests_1; - switch (test.tag) { - case 1: { - if (test.fields[2].tag === 2) { - matchResult = 1; - } - else { - matchResult = 4; - } - break; - } - case 2: { - matchResult = 2; - tests = test.fields[1]; - break; - } - case 3: { - matchResult = 3; - tests_1 = test.fields[1]; - break; - } - default: - if (test.fields[2].tag === 2) { - matchResult = 0; - } - else { - matchResult = 4; - } - } - switch (matchResult) { - case 0: - return true; - case 1: - return true; - case 2: - return exists_1(Pyxpecto_isFocused, tests); - case 3: - return exists_1(Pyxpecto_isFocused, tests_1); - default: - return false; - } -} - -function Pyxpecto_flattenTests(lastName, _arg) { - switch (_arg.tag) { - case 1: { - const name_1 = _arg.fields[0]; - return singleton(new TestCase(1, [isNullOrWhiteSpace(lastName) ? name_1 : toText(printf("%s - %s"))(lastName)(name_1), _arg.fields[1], _arg.fields[2]])); - } - case 2: - return toList(delay(() => collect((test_2) => Pyxpecto_flattenTests(_arg.fields[0], test_2), _arg.fields[1]))); - case 3: - return toList(delay(() => collect((test_3) => Pyxpecto_flattenTests(_arg.fields[0], test_3), _arg.fields[1]))); - default: { - const name = _arg.fields[0]; - return singleton(new TestCase(0, [isNullOrWhiteSpace(lastName) ? name : toText(printf("%s - %s"))(lastName)(name), _arg.fields[1], _arg.fields[2]])); - } - } -} - -export function Pyxpecto_checkFocused(test) { - let hasFocused = false; - const loop = (_arg) => { - let matchResult, tests; - switch (_arg.tag) { - case 0: { - if (_arg.fields[2].tag === 2) { - matchResult = 0; - } - else { - matchResult = 1; - } - break; - } - case 3: { - matchResult = 2; - tests = _arg.fields[1]; - break; - } - case 2: { - matchResult = 2; - tests = _arg.fields[1]; - break; - } - default: - if (_arg.fields[2].tag === 2) { - matchResult = 0; - } - else { - matchResult = 1; - } - } - switch (matchResult) { - case 0: { - hasFocused = true; - break; - } - case 1: { - break; - } - case 2: { - const enumerator = getEnumerator(tests); - try { - while (enumerator["System.Collections.IEnumerator.MoveNext"]()) { - loop(enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]()); - } - } - finally { - disposeSafe(enumerator); - } - break; - } - } - }; - loop(test); - return hasFocused; -} - -export const Pyxpecto_PyBindings_cmd_args = sys.argv; - -export class Pyxpecto_CustomTestRunner { - constructor(test) { - const hasFocused = Pyxpecto_checkFocused(test); - let verifyFocusedAllowed; - if (contains_1("--fail-on-focused-tests", Pyxpecto_PyBindings_cmd_args, { - Equals: (x, y) => (x === y), - GetHashCode: stringHash, - }) && hasFocused) { - throw new Error(`${'\033[91m'}Cannot run focused tests with '${"--fail-on-focused-tests"}' commandline arg.${'\033[0m'}`); - } - else { - verifyFocusedAllowed = void 0; - } - this["SuccessfulTests@"] = 0; - this["FailedTests@"] = 0; - this["IgnoredTests@"] = 0; - this["HasFocused@"] = hasFocused; - } - printSuccessMsg(name) { - const this$ = this; - toConsole(`${this$.HasFocused ? "💎 | " : ""}✔️ ${name}`); - } - printErrorMsg(name, msg) { - const this$ = this; - toConsole(`${this$.HasFocused ? "💎 | " : ""}❌ ${name} -${msg}`); - } - printSkipPendingMsg(name) { - toConsole(printf("🚧 skipping \'%s\' due to it being marked as pending"))(name); - } - get SuccessfulTests() { - const __ = this; - return __["SuccessfulTests@"] | 0; - } - set SuccessfulTests(v) { - const __ = this; - __["SuccessfulTests@"] = (v | 0); - } - get FailedTests() { - const __ = this; - return __["FailedTests@"] | 0; - } - set FailedTests(v) { - const __ = this; - __["FailedTests@"] = (v | 0); - } - get IgnoredTests() { - const __ = this; - return __["IgnoredTests@"] | 0; - } - set IgnoredTests(v) { - const __ = this; - __["IgnoredTests@"] = (v | 0); - } - get HasFocused() { - const __ = this; - return __["HasFocused@"]; - } - get SumTests() { - const this$ = this; - return (this$.SuccessfulTests + this$.FailedTests) | 0; - } - RunSyncTest(name, body) { - const this$ = this; - try { - body(); - this$.SuccessfulTests = ((this$.SuccessfulTests + 1) | 0); - this$.printSuccessMsg(name); - } - catch (e) { - this$.FailedTests = ((this$.FailedTests + 1) | 0); - const arg_1 = e.message; - this$.printErrorMsg(name, arg_1); - } - } - RunAsyncTest(name, body) { - const this$ = this; - try { - runSynchronously(singleton_1.Delay(() => singleton_1.Bind(body, () => { - this$.SuccessfulTests = ((this$.SuccessfulTests + 1) | 0); - this$.printSuccessMsg(name); - return singleton_1.Zero(); - }))); - } - catch (e) { - this$.FailedTests = ((this$.FailedTests + 1) | 0); - const arg_2 = e.message; - this$.printErrorMsg(name, arg_2); - } - } - SkipPendingTest(name) { - const this$ = this; - this$.IgnoredTests = ((this$.IgnoredTests + 1) | 0); - this$.printSkipPendingMsg(name); - } - SkipUnfocusedTest() { - const this$ = this; - this$.IgnoredTests = ((this$.IgnoredTests + 1) | 0); - } -} - -export function Pyxpecto_CustomTestRunner_$reflection() { - return class_type("Fable.Pyxpecto.Pyxpecto.CustomTestRunner", void 0, Pyxpecto_CustomTestRunner); -} - -export function Pyxpecto_CustomTestRunner_$ctor_Z1F0D1F49(test) { - return new Pyxpecto_CustomTestRunner(test); -} - -function Pyxpecto_runViaPy(test) { - const runner = new Pyxpecto_CustomTestRunner(test); - const run = (runner_1, test_1) => { - let matchResult, name_2, testCases; - switch (test_1.tag) { - case 1: { - matchResult = 1; - break; - } - case 3: { - matchResult = 2; - name_2 = test_1.fields[0]; - testCases = test_1.fields[1]; - break; - } - case 2: { - matchResult = 2; - name_2 = test_1.fields[0]; - testCases = test_1.fields[1]; - break; - } - default: - matchResult = 0; - } - switch (matchResult) { - case 0: { - const test_2 = test_1.fields[1]; - const name = test_1.fields[0]; - const focus = test_1.fields[2]; - const matchValue = runner_1.HasFocused; - let matchResult_1; - if (matchValue) { - if (focus.tag === 2) { - matchResult_1 = 2; - } - else { - matchResult_1 = 3; - } - } - else { - switch (focus.tag) { - case 0: { - matchResult_1 = 0; - break; - } - case 1: { - matchResult_1 = 1; - break; - } - default: - matchResult_1 = 3; - } - } - switch (matchResult_1) { - case 0: { - runner_1.RunSyncTest(name, test_2); - break; - } - case 1: { - runner_1.SkipPendingTest(name); - break; - } - case 2: { - runner_1.RunSyncTest(name, test_2); - break; - } - case 3: { - runner_1.SkipUnfocusedTest(); - break; - } - } - break; - } - case 1: { - const test_3 = test_1.fields[1]; - const name_1 = test_1.fields[0]; - const focus_1 = test_1.fields[2]; - const matchValue_2 = runner_1.HasFocused; - let matchResult_2; - if (matchValue_2) { - if (focus_1.tag === 2) { - matchResult_2 = 2; - } - else { - matchResult_2 = 3; - } - } - else { - switch (focus_1.tag) { - case 0: { - matchResult_2 = 0; - break; - } - case 1: { - matchResult_2 = 1; - break; - } - default: - matchResult_2 = 3; - } - } - switch (matchResult_2) { - case 0: { - runner_1.RunAsyncTest(name_1, test_3); - break; - } - case 1: { - runner_1.SkipPendingTest(name_1); - break; - } - case 2: { - runner_1.RunAsyncTest(name_1, test_3); - break; - } - case 3: { - runner_1.SkipUnfocusedTest(); - break; - } - } - break; - } - case 2: { - const list_1 = collect_1((t) => Pyxpecto_flattenTests(name_2, t), testCases); - iterate(curry2(run)(runner_1), list_1); - break; - } - } - }; - toConsole(printf("🚀 start running tests ...")); - run(runner, test); - const innerMsgString = `${'\033[36m'}${runner.SumTests}${'\033[0m'} tests run - ${'\033[92m'}${runner.SuccessfulTests}${'\033[0m'} passed, ${'\033[36m'}${runner.IgnoredTests}${'\033[0m'} ignored, ${'\033[91m'}${runner.FailedTests}${'\033[0m'} failed`; - const msg = toString(StringBuilder__AppendLine_Z721C83C5(StringBuilder__AppendLine_Z721C83C5(StringBuilder__AppendLine_Z721C83C5(StringBuilder_$ctor(), "-------------------------------------------------------------------------------"), innerMsgString), "-------------------------------------------------------------------------------")); - toConsole(printf("%s"))(msg); - const matchValue_4 = runner.FailedTests | 0; - if (matchValue_4 === 1) { - toConsole(`${'\033[91m'}${runner.FailedTests} test failed!${'\033[0m'}`); - return 1; - } - else if (matchValue_4 > 1) { - toConsole(`${'\033[91m'}${matchValue_4} tests failed!${'\033[0m'}`); - return 1; - } - else { - toConsole(`${'\033[92m'}Success!${'\033[0m'}`); - return 0; - } -} - -function Pyxpecto_runViaDotnet(test) { - throw new Error("Currently not implemented, use Expecto for now."); - return 1; -} - -export function Pyxpecto_runTests(test) { - return Pyxpecto_runViaPy(test); -} - diff --git a/tests/py/main.py b/tests/py/main.py deleted file mode 100644 index 6eb99d1..0000000 --- a/tests/py/main.py +++ /dev/null @@ -1,504 +0,0 @@ -from __future__ import annotations -from math import (nan, inf) -import sys -from typing import Any -from src.pyxpecto import Test_TestCaseBuilder__ctor_Z69FFBD2B -from src.pyxpecto import (Test_testSequenced, Test_testList, Test_testCaseAsync, Test_testCase, Expect_isTrue, TestCase, Expect_isFalse, Expect_isOk, Expect_throwsC, Expect_isEmpty, Expect_isNonEmpty, Expect_wantOk, Expect_stringContains, Expect_isError, Expect_wantError, Expect_isSome, Expect_wantSome, Expect_isNone, Expect_isNotNull, Expect_isNull, Expect_isNotNaN, Expect_throws, Expect_floatClose, AccuracyModule_low, Expect_floatLessThanOrClose, Expect_floatGreaterThanOrClose, Expect_isNotInfinity, Test_ptestCase, Test_ptestCaseAsync, FocusState, Test_TestCaseBuilder, Test_TestCaseBuilder__Run_3A5B6456, Test_TestCaseBuilder__Delay_1505, Expect_containsAll, Test_TestCaseBuilder__Zero, Expect_notEqual, Test_ftestCase, Test_ftestCaseAsync, Pyxpecto_runTests) -from fable_modules.fable_library.async_ import sleep -from fable_modules.fable_library.async_builder import (singleton, Async) -from fable_modules.fable_library.choice import FSharpResult_2 -from fable_modules.fable_library.double import divide -from fable_modules.fable_library.list import (singleton as singleton_1, of_array) -from fable_modules.fable_library.string_ import (to_fail, printf) -from fable_modules.fable_library.types import Array -from fable_modules.fable_library.util import (assert_equal, to_enumerable, equals) - -def _arrow6(__unit: None=None) -> Async[None]: - def _arrow5(__unit: None=None) -> Async[None]: - return singleton.Return() - - return singleton.Bind(sleep(1000), _arrow5) - - -def body_1(__unit: None=None) -> None: - Expect_isTrue(True)("this should work") - - -def _arrow8(__unit: None=None) -> Async[None]: - def _arrow7(__unit: None=None) -> Async[None]: - return singleton.Return() - - return singleton.Bind(sleep(1000), _arrow7) - - -def body_3(__unit: None=None) -> None: - Expect_isTrue(True)("") - - -def body_4(__unit: None=None) -> None: - Expect_isTrue(True)("") - - -def _arrow13(__unit: None=None) -> Async[None]: - def _arrow12(__unit: None=None) -> Async[None]: - Expect_isTrue(True)("this should work") - return singleton.Zero() - - return singleton.Bind(sleep(1000), _arrow12) - - -tests_sequential: TestCase = Test_testSequenced(Test_testList("Sequential", of_array([Test_testCaseAsync("one", singleton.Delay(_arrow6)), Test_testCase("sync one", body_1), Test_testCaseAsync("two", singleton.Delay(_arrow8)), Test_testCase("sync two", body_3), Test_testList("Many", singleton_1(Test_testCase("syncThree", body_4))), Test_testCaseAsync("three", singleton.Delay(_arrow13))]))) - -def body(__unit: None=None) -> None: - actual: int = 2 - if actual == 2: - assert_equal(actual, 2, "Should be equal") - - else: - raise Exception((((((((((((((" Expected: " + ('\033[96m')) + "") + str(2)) + "") + ('\033[0m')) + " \n\b Actual: ") + ('\033[91m')) + "") + str(actual)) + "") + ('\033[0m')) + " \n\b Message: ") + "Should be equal") + "") - - - -def body_1(__unit: None=None) -> None: - Expect_isFalse(False)("Should be equal") - - -def body_2(__unit: None=None) -> None: - raise Exception((((((((((((((" Expected: " + ('\033[96m')) + "") + str(3)) + "") + ('\033[0m')) + " \n\b Actual: ") + ('\033[91m')) + "") + str(2)) + "") + ('\033[0m')) + " \n\b Message: ") + "They are the same") + "") - - -def body_3(__unit: None=None) -> None: - Expect_isOk(FSharpResult_2(0, True), "Should be Ok") - - -def body_4(__unit: None=None) -> None: - def case(__unit: None=None) -> None: - Expect_isOk(FSharpResult_2(1, "fails"), "Should fail") - raise Exception((((((((((((((" Expected: " + ('\033[96m')) + "") + str(False)) + "") + ('\033[0m')) + " \n\b Actual: ") + ('\033[91m')) + "") + str(True)) + "") + ('\033[0m')) + " \n\b Message: ") + "Should not be tested") + "") - - def catch(exn: Exception) -> None: - actual_5: str = str(exn) - if actual_5 == "Should fail. Expected Ok, was Error(\"fails\").": - assert_equal(actual_5, "Should fail. Expected Ok, was Error(\"fails\").", "Error messages should be the same") - - else: - raise Exception((((((((((((((" Expected: " + ('\033[96m')) + "") + "Should fail. Expected Ok, was Error(\"fails\").") + "") + ('\033[0m')) + " \n\b Actual: ") + ('\033[91m')) + "") + actual_5) + "") + ('\033[0m')) + " \n\b Message: ") + "Error messages should be the same") + "") - - - Expect_throwsC(case, catch) - - -def body_5(__unit: None=None) -> None: - Expect_isEmpty(to_enumerable([]), "Should be empty") - - -def body_6(__unit: None=None) -> None: - def case_1(__unit: None=None) -> None: - Expect_isEmpty(to_enumerable([1]), "Should fail") - raise Exception((((((((((((((" Expected: " + ('\033[96m')) + "") + str(False)) + "") + ('\033[0m')) + " \n\b Actual: ") + ('\033[91m')) + "") + str(True)) + "") + ('\033[0m')) + " \n\b Message: ") + "Should not be tested") + "") - - def catch_1(exn_1: Exception) -> None: - actual_9: str = str(exn_1) - if actual_9 == "Should fail. Should be empty.": - assert_equal(actual_9, "Should fail. Should be empty.", "Error messages should be the same") - - else: - raise Exception((((((((((((((" Expected: " + ('\033[96m')) + "") + "Should fail. Should be empty.") + "") + ('\033[0m')) + " \n\b Actual: ") + ('\033[91m')) + "") + actual_9) + "") + ('\033[0m')) + " \n\b Message: ") + "Error messages should be the same") + "") - - - Expect_throwsC(case_1, catch_1) - - -def body_7(__unit: None=None) -> None: - Expect_isNonEmpty(to_enumerable([1]), "Should not be empty") - - -def body_8(__unit: None=None) -> None: - def case_2(__unit: None=None) -> None: - Expect_isNonEmpty(to_enumerable([]), "Should fail") - raise Exception((((((((((((((" Expected: " + ('\033[96m')) + "") + str(False)) + "") + ('\033[0m')) + " \n\b Actual: ") + ('\033[91m')) + "") + str(True)) + "") + ('\033[0m')) + " \n\b Message: ") + "Should not be tested") + "") - - def catch_2(exn_2: Exception) -> None: - actual_13: str = str(exn_2) - if actual_13 == "Should fail. Should not be empty.": - assert_equal(actual_13, "Should fail. Should not be empty.", "Error messages should be the same") - - else: - raise Exception((((((((((((((" Expected: " + ('\033[96m')) + "") + "Should fail. Should not be empty.") + "") + ('\033[0m')) + " \n\b Actual: ") + ('\033[91m')) + "") + actual_13) + "") + ('\033[0m')) + " \n\b Message: ") + "Error messages should be the same") + "") - - - Expect_throwsC(case_2, catch_2) - - -def body_9(__unit: None=None) -> None: - actual_15: bool = Expect_wantOk(FSharpResult_2(0, True), "Should be Ok") - if actual_15 == True: - assert_equal(actual_15, True, "Should be true") - - else: - raise Exception((((((((((((((" Expected: " + ('\033[96m')) + "") + str(True)) + "") + ('\033[0m')) + " \n\b Actual: ") + ('\033[91m')) + "") + str(actual_15)) + "") + ('\033[0m')) + " \n\b Message: ") + "Should be true") + "") - - - -def body_10(__unit: None=None) -> None: - def case_3(__unit: None=None) -> None: - Expect_wantOk(FSharpResult_2(1, True), "Should fail") - raise Exception((((((((((((((" Expected: " + ('\033[96m')) + "") + str(False)) + "") + ('\033[0m')) + " \n\b Actual: ") + ('\033[91m')) + "") + str(True)) + "") + ('\033[0m')) + " \n\b Message: ") + "Should not be tested") + "") - - def catch_3(exn_3: Exception) -> None: - Expect_stringContains(str(exn_3), "Expected Ok", "Error contains the error message") - - Expect_throwsC(case_3, catch_3) - - -def body_11(__unit: None=None) -> None: - Expect_isError(FSharpResult_2(1, "Is Error"), "Should be Error") - - -def body_12(__unit: None=None) -> None: - def case_4(__unit: None=None) -> None: - Expect_isError(FSharpResult_2(0, True), "Should fail") - raise Exception((((((((((((((" Expected: " + ('\033[96m')) + "") + str(False)) + "") + ('\033[0m')) + " \n\b Actual: ") + ('\033[91m')) + "") + str(True)) + "") + ('\033[0m')) + " \n\b Message: ") + "Should not be tested") + "") - - def catch_4(exn_4: Exception) -> None: - Expect_stringContains(str(exn_4), "Expected Error", "error message part is present") - - Expect_throwsC(case_4, catch_4) - - -def body_13(__unit: None=None) -> None: - actual_22: bool = Expect_wantError(FSharpResult_2(1, True), "Should be Error") - if actual_22 == True: - assert_equal(actual_22, True, "Should be true") - - else: - raise Exception((((((((((((((" Expected: " + ('\033[96m')) + "") + str(True)) + "") + ('\033[0m')) + " \n\b Actual: ") + ('\033[91m')) + "") + str(actual_22)) + "") + ('\033[0m')) + " \n\b Message: ") + "Should be true") + "") - - - -def body_14(__unit: None=None) -> None: - def case_5(__unit: None=None) -> None: - Expect_wantError(FSharpResult_2(0, True), "Should fail") - raise Exception((((((((((((((" Expected: " + ('\033[96m')) + "") + str(False)) + "") + ('\033[0m')) + " \n\b Actual: ") + ('\033[91m')) + "") + str(True)) + "") + ('\033[0m')) + " \n\b Message: ") + "Should not be tested") + "") - - def catch_5(exn_5: Exception) -> None: - Expect_stringContains(str(exn_5), "Expected Error", "Error message contains the correct error") - - Expect_throwsC(case_5, catch_5) - - -def body_15(__unit: None=None) -> None: - Expect_isSome(True, "Should be Some") - - -def body_16(__unit: None=None) -> None: - def case_6(__unit: None=None) -> None: - Expect_isSome(None, "Should fail") - raise Exception((((((((((((((" Expected: " + ('\033[96m')) + "") + str(False)) + "") + ('\033[0m')) + " \n\b Actual: ") + ('\033[91m')) + "") + str(True)) + "") + ('\033[0m')) + " \n\b Message: ") + "Should not be tested") + "") - - def catch_6(exn_6: Exception) -> None: - actual_28: str = str(exn_6) - if actual_28 == "Should fail. Expected Some _, was None.": - assert_equal(actual_28, "Should fail. Expected Some _, was None.", "Error messages should be the same") - - else: - raise Exception((((((((((((((" Expected: " + ('\033[96m')) + "") + "Should fail. Expected Some _, was None.") + "") + ('\033[0m')) + " \n\b Actual: ") + ('\033[91m')) + "") + actual_28) + "") + ('\033[0m')) + " \n\b Message: ") + "Error messages should be the same") + "") - - - Expect_throwsC(case_6, catch_6) - - -def body_17(__unit: None=None) -> None: - actual_30: bool = Expect_wantSome(True, "Should be Some") - if actual_30 == True: - assert_equal(actual_30, True, "Should be true") - - else: - raise Exception((((((((((((((" Expected: " + ('\033[96m')) + "") + str(True)) + "") + ('\033[0m')) + " \n\b Actual: ") + ('\033[91m')) + "") + str(actual_30)) + "") + ('\033[0m')) + " \n\b Message: ") + "Should be true") + "") - - - -def body_18(__unit: None=None) -> None: - def case_7(__unit: None=None) -> None: - Expect_isSome(None, "Should fail") - raise Exception((((((((((((((" Expected: " + ('\033[96m')) + "") + str(False)) + "") + ('\033[0m')) + " \n\b Actual: ") + ('\033[91m')) + "") + str(True)) + "") + ('\033[0m')) + " \n\b Message: ") + "Should not be tested") + "") - - def catch_7(exn_7: Exception) -> None: - actual_33: str = str(exn_7) - if actual_33 == "Should fail. Expected Some _, was None.": - assert_equal(actual_33, "Should fail. Expected Some _, was None.", "Error messages should be the same") - - else: - raise Exception((((((((((((((" Expected: " + ('\033[96m')) + "") + "Should fail. Expected Some _, was None.") + "") + ('\033[0m')) + " \n\b Actual: ") + ('\033[91m')) + "") + actual_33) + "") + ('\033[0m')) + " \n\b Message: ") + "Error messages should be the same") + "") - - - Expect_throwsC(case_7, catch_7) - - -def body_19(__unit: None=None) -> None: - Expect_isNone(None, "Should be Some") - - -def body_20(__unit: None=None) -> None: - def case_8(__unit: None=None) -> None: - Expect_isNone(True, "Should fail") - raise Exception((((((((((((((" Expected: " + ('\033[96m')) + "") + str(False)) + "") + ('\033[0m')) + " \n\b Actual: ") + ('\033[91m')) + "") + str(True)) + "") + ('\033[0m')) + " \n\b Message: ") + "Should not be tested") + "") - - def catch_8(exn_8: Exception) -> None: - actual_37: str = str(exn_8) - if actual_37 == "Should fail. Expected None, was Some(true).": - assert_equal(actual_37, "Should fail. Expected None, was Some(true).", "Error messages should be the same") - - else: - raise Exception((((((((((((((" Expected: " + ('\033[96m')) + "") + "Should fail. Expected None, was Some(true).") + "") + ('\033[0m')) + " \n\b Actual: ") + ('\033[91m')) + "") + actual_37) + "") + ('\033[0m')) + " \n\b Message: ") + "Error messages should be the same") + "") - - - Expect_throwsC(case_8, catch_8) - - -def body_21(__unit: None=None) -> None: - Expect_isNotNull("not null")("Should not be null") - - -def body_22(__unit: None=None) -> None: - Expect_isNull(None)("Should not be null") - - -def body_23(__unit: None=None) -> None: - Expect_isNotNaN(20.4, "Should not be nan") - - -def body_24(__unit: None=None) -> None: - def case_9(__unit: None=None) -> None: - actual_41: float = nan - Expect_isNotNaN(actual_41, "Should fail") - - Expect_throws(case_9, "Should have failed") - - -def body_25(__unit: None=None) -> None: - Expect_floatClose(AccuracyModule_low, 0.1, 0.1, "Should be close enough") - - -def body_26(__unit: None=None) -> None: - def case_10(__unit: None=None) -> None: - Expect_floatClose(AccuracyModule_low, 0.1, 2.0, "Should be far enough apart") - - Expect_throws(case_10, "Should have failed") - - -def body_27(__unit: None=None) -> None: - Expect_floatLessThanOrClose(AccuracyModule_low, 0.1, 0.1, "Should be close enough") - - -def body_28(__unit: None=None) -> None: - def case_11(__unit: None=None) -> None: - Expect_floatLessThanOrClose(AccuracyModule_low, 2.0, 1.0, "Should be far enough apart") - - Expect_throws(case_11, "Should have failed") - - -def body_29(__unit: None=None) -> None: - Expect_floatGreaterThanOrClose(AccuracyModule_low, 0.123, 0.123, "Should be close enough") - - -def body_30(__unit: None=None) -> None: - def case_12(__unit: None=None) -> None: - Expect_floatGreaterThanOrClose(AccuracyModule_low, 1.0, 2.0, "Should be far enough apart") - - Expect_throws(case_12, "Should have failed") - - -def body_31(__unit: None=None) -> None: - def case_13(__unit: None=None) -> None: - raise Exception("Should fail") - - def catch_9(exn_9: Exception) -> None: - actual_42: str = str(exn_9) - if actual_42 == "Should fail": - assert_equal(actual_42, "Should fail", "Error messages should be the same") - - else: - raise Exception((((((((((((((" Expected: " + ('\033[96m')) + "") + "Should fail") + "") + ('\033[0m')) + " \n\b Actual: ") + ('\033[91m')) + "") + actual_42) + "") + ('\033[0m')) + " \n\b Message: ") + "Error messages should be the same") + "") - - - Expect_throwsC(case_13, catch_9) - - -def body_32(__unit: None=None) -> None: - def case_14(__unit: None=None) -> None: - to_fail(printf("%s%s"))("Should fail")("!") - - def catch_10(exn_10: Exception) -> None: - actual_43: str = str(exn_10) - if actual_43 == "Should fail!": - assert_equal(actual_43, "Should fail!", "Error messages should be the same") - - else: - raise Exception((((((((((((((" Expected: " + ('\033[96m')) + "") + "Should fail!") + "") + ('\033[0m')) + " \n\b Actual: ") + ('\033[91m')) + "") + actual_43) + "") + ('\033[0m')) + " \n\b Message: ") + "Error messages should be the same") + "") - - - Expect_throwsC(case_14, catch_10) - - -def body_33(__unit: None=None) -> None: - Expect_isNotInfinity(20.4, "Shouldn\'t be infinity") - - -def body_34(__unit: None=None) -> None: - def case_15(__unit: None=None) -> None: - actual_45: float = inf - Expect_isNotInfinity(actual_45, "Should fail") - - Expect_throws(case_15, "Should have failed") - - -def _arrow19(__unit: None=None) -> Async[None]: - def _arrow18(__unit: None=None) -> Async[None]: - def _arrow16(__unit: None=None) -> Async[int]: - return singleton.Return(21) - - def _arrow17(_arg_34: int) -> Async[None]: - actual_46: int = (_arg_34 * 2) or 0 - if actual_46 == 42: - assert_equal(actual_46, 42, "Should be equal") - - else: - raise Exception((((((((((((((" Expected: " + ('\033[96m')) + "") + str(42)) + "") + ('\033[0m')) + " \n\b Actual: ") + ('\033[91m')) + "") + str(actual_46)) + "") + ('\033[0m')) + " \n\b Message: ") + "Should be equal") + "") - - return singleton.Zero() - - return singleton.Bind(singleton.Delay(_arrow16), _arrow17) - - return singleton.Bind(sleep(3000), _arrow18) - - -def body_36(__unit: None=None) -> None: - raise Exception("Shouldn\'t be running this test") - - -def _arrow20(__unit: None=None) -> Async[None]: - raise Exception("Shouldn\'t be running this test") - return singleton.Zero() - - -def body_38(__unit: None=None) -> None: - Expect_stringContains("Hello, World!", "World", "Should contain string") - - -def body_39(__unit: None=None) -> None: - try: - Expect_stringContains("Hello, Mocha!", "World", "Should fail") - raise Exception((((((((((((((" Expected: " + ('\033[96m')) + "") + str(False)) + "") + ('\033[0m')) + " \n\b Actual: ") + ('\033[91m')) + "") + str(True)) + "") + ('\033[0m')) + " \n\b Message: ") + "Should not be tested") + "") - - except Exception as ex: - actual_48: str = str(ex) - if actual_48 == "Should fail. Expected subject string \'Hello, Mocha!\' to contain substring \'World\'.": - assert_equal(actual_48, "Should fail. Expected subject string \'Hello, Mocha!\' to contain substring \'World\'.", "Error messages should be the same") - - else: - raise Exception((((((((((((((" Expected: " + ('\033[96m')) + "") + "Should fail. Expected subject string \'Hello, Mocha!\' to contain substring \'World\'.") + "") + ('\033[0m')) + " \n\b Actual: ") + ('\033[91m')) + "") + actual_48) + "") + ('\033[0m')) + " \n\b Message: ") + "Error messages should be the same") + "") - - - - -def _arrow26(__unit: None=None) -> TestCase: - _builder_3: Test_TestCaseBuilder = Test_TestCaseBuilder__ctor_Z69FFBD2B("identical sequence", FocusState(0)) - def _arrow23(__unit: None=None) -> None: - Expect_containsAll(to_enumerable([21, 37]), to_enumerable([21, 37]), "Identical sequences") - Test_TestCaseBuilder__Zero(_builder_3) - - return Test_TestCaseBuilder__Run_3A5B6456(_builder_3, Test_TestCaseBuilder__Delay_1505(_builder_3, _arrow23)) - - -def _arrow28(__unit: None=None) -> TestCase: - _builder_4: Test_TestCaseBuilder = Test_TestCaseBuilder__ctor_Z69FFBD2B("sequence contains all in different order", FocusState(0)) - def _arrow27(__unit: None=None) -> None: - Expect_containsAll(to_enumerable([21, 37]), to_enumerable([37, 21]), "Same elements in different order") - Test_TestCaseBuilder__Zero(_builder_4) - - return Test_TestCaseBuilder__Run_3A5B6456(_builder_4, Test_TestCaseBuilder__Delay_1505(_builder_4, _arrow27)) - - -tests_basic: TestCase = Test_testList("Basic", of_array([Test_testCase("testCase works with numbers", body), Test_testCase("isFalse works", body_1), Test_testCase("areEqual with msg", body_2), Test_testCase("isOk works correctly", body_3), Test_testCase("isOk fails correctly", body_4), Test_testCase("isEmpty works correctly", body_5), Test_testCase("isEmpty fails correctly", body_6), Test_testCase("isNonEmpty works correctly", body_7), Test_testCase("isNonEmpty fails correctly", body_8), Test_testCase("wantOk works correctly", body_9), Test_testCase("wantOk fails correctly", body_10), Test_testCase("isError works correctly", body_11), Test_testCase("isError fails correctly", body_12), Test_testCase("wantError works correctly", body_13), Test_testCase("wantError fails correctly", body_14), Test_testCase("isSome works correctly", body_15), Test_testCase("isSome fails correctly", body_16), Test_testCase("wantSome works correctly", body_17), Test_testCase("wantSome fails correctly", body_18), Test_testCase("isNone works correctly", body_19), Test_testCase("isNone fails correctly", body_20), Test_testCase("isNotNull works correctly", body_21), Test_testCase("isNull works correctly", body_22), Test_testCase("isNotNaN works correctly", body_23), Test_testCase("isNotNaN fails correctly", body_24), Test_testCase("floatClose works correctly", body_25), Test_testCase("floatClose fails correctly", body_26), Test_testCase("floatLessThanOrClose works correctly", body_27), Test_testCase("floatLessThanOrClose fails correctly", body_28), Test_testCase("floatGreaterThanOrClose works correctly", body_29), Test_testCase("floatGreaterThanOrClose fails correctly", body_30), Test_testCase("failwith fails correctly", body_31), Test_testCase("failwithf fails correctly", body_32), Test_testCase("isNotInfinity works correctly", body_33), Test_testCase("isNotInfinity fails correctly", body_34), Test_testCaseAsync("testCaseAsync works", singleton.Delay(_arrow19)), Test_ptestCase("skipping this one", body_36), Test_ptestCaseAsync("skipping this one async", singleton.Delay(_arrow20)), Test_testCase("stringContains works correctly", body_38), Test_testCase("stringContains fails correctly", body_39), Test_testList("containsAll", of_array([_arrow26(), _arrow28()]))])) - -def body(__unit: None=None) -> None: - actual: float = divide(31415.0, 10000.0) - if actual == 3.1415: - assert_equal(actual, 3.1415, "Should be equal") - - else: - raise Exception((((((((((((((" Expected: " + ('\033[96m')) + "") + str(3.1415)) + "") + ('\033[0m')) + " \n\b Actual: ") + ('\033[91m')) + "") + str(actual)) + "") + ('\033[0m')) + " \n\b Message: ") + "Should be equal") + "") - - - -second_module_tests: TestCase = Test_testList("second Module tests", singleton_1(Test_testCase("module works properly", body))) - -def body(__unit: None=None) -> None: - actual_1: dict[str, Any] = { - "one": "one", - "two": 2 - } - expected_1: dict[str, Any] = { - "one": "one", - "two": 2 - } - if equals(actual_1, expected_1): - assert_equal(actual_1, expected_1, "Should be equal") - - else: - raise Exception((((((((((((((" Expected: " + ('\033[96m')) + "") + str(expected_1)) + "") + ('\033[0m')) + " \n\b Actual: ") + ('\033[91m')) + "") + str(actual_1)) + "") + ('\033[0m')) + " \n\b Message: ") + "Should be equal") + "") - - - -def body_1(__unit: None=None) -> None: - Expect_notEqual({ - "one": "one", - "two": 2 - }, { - "one": "one", - "two": 1 - }, "Should be equal") - - -structural_equality_tests: TestCase = Test_testList("testing records", of_array([Test_testCase("they are equal", body), Test_testCase("they are not equal", body_1)])) - -def body(__unit: None=None) -> None: - Expect_isTrue(True)("Should be true") - - -nested_test_case: TestCase = Test_testList("Nested", singleton_1(Test_testList("Nested even more", singleton_1(Test_testCase("Nested test case", body))))) - -def body(__unit: None=None) -> None: - actual: int = 2 - if actual == 2: - assert_equal(actual, 2, "Should be equal") - - else: - raise Exception((((((((((((((" Expected: " + ('\033[96m')) + "") + str(2)) + "") + ('\033[0m')) + " \n\b Actual: ") + ('\033[91m')) + "") + str(actual)) + "") + ('\033[0m')) + " \n\b Message: ") + "Should be equal") + "") - - - -def _arrow29(__unit: None=None) -> Async[None]: - actual_1: int = 2 - if actual_1 == 2: - assert_equal(actual_1, 2, "Should be equal") - - else: - raise Exception((((((((((((((" Expected: " + ('\033[96m')) + "") + str(2)) + "") + ('\033[0m')) + " \n\b Actual: ") + ('\033[91m')) + "") + str(actual_1)) + "") + ('\033[0m')) + " \n\b Message: ") + "Should be equal") + "") - - return singleton.Zero() - - -focused_tests_cases: TestCase = Test_testList("Focused", of_array([Test_ftestCase("Focused sync test", body), Test_ftestCaseAsync("Focused async test", singleton.Delay(_arrow29))])) - -all: TestCase = Test_testList("All", of_array([tests_sequential, tests_basic, second_module_tests, structural_equality_tests, nested_test_case])) - -def main(argv: Array[str]) -> int: - return Pyxpecto_runTests(all) - - -if __name__ == "__main__": - main(sys.argv[1:]) - - diff --git a/tests/py/src/pyxpecto.py b/tests/py/src/pyxpecto.py deleted file mode 100644 index ce24f4e..0000000 --- a/tests/py/src/pyxpecto.py +++ /dev/null @@ -1,1003 +0,0 @@ -from __future__ import annotations -from dataclasses import dataclass -from math import (isnan, isinf) -import sys -from typing import (Any, List, Callable, TypeVar, Optional) -from fable_modules.fable_library.array_ import contains as contains_1 -from fable_modules.fable_library.async_ import run_synchronously -from fable_modules.fable_library.async_builder import (Async, singleton as singleton_1) -from fable_modules.fable_library.choice import FSharpResult_2 -from fable_modules.fable_library.fsharp_core import Operators_Using -from fable_modules.fable_library.list import (FSharpList, singleton, of_seq, filter, contains, is_empty as is_empty_1, exists as exists_1, collect as collect_1, iterate) -from fable_modules.fable_library.option import value as value_2 -from fable_modules.fable_library.reflection import (TypeInfo, union_type, string_type, unit_type, lambda_type, class_type, list_type, float64_type, record_type) -from fable_modules.fable_library.seq import (is_empty, exists, for_all, length, to_list, delay, collect) -from fable_modules.fable_library.string_ import (to_fail, printf, to_text, is_null_or_white_space, to_console) -from fable_modules.fable_library.system_text import (StringBuilder__AppendLine_Z721C83C5, StringBuilder__ctor) -from fable_modules.fable_library.types import (Array, Union, Record, to_string) -from fable_modules.fable_library.util import (IEnumerable_1, get_enumerator, assert_not_equal, equals, assert_equal, structural_hash, max, compare_primitives, string_hash, curry2) - -__G = TypeVar("__G") - -__E = TypeVar("__E") - -__F = TypeVar("__F") - -__D = TypeVar("__D") - -__C = TypeVar("__C") - -__B = TypeVar("__B") - -__A = TypeVar("__A") - -__K = TypeVar("__K") - -__J = TypeVar("__J") - -__I = TypeVar("__I") - -__H = TypeVar("__H") - -_A = TypeVar("_A") - -_B = TypeVar("_B") - -__A_ = TypeVar("__A_") - -def _expr9() -> TypeInfo: - return union_type("Fable.Pyxpecto.FocusState", [], FocusState, lambda: [[], [], []]) - - -class FocusState(Union): - def __init__(self, tag: int, *fields: Any) -> None: - super().__init__() - self.tag: int = tag or 0 - self.fields: Array[Any] = list(fields) - - @staticmethod - def cases() -> List[str]: - return ["Normal", "Pending", "Focused"] - - -FocusState_reflection = _expr9 - -def _expr10() -> TypeInfo: - return union_type("Fable.Pyxpecto.TestCase", [], TestCase, lambda: [[("Item1", string_type), ("Item2", lambda_type(unit_type, unit_type)), ("Item3", FocusState_reflection())], [("Item1", string_type), ("Item2", class_type("Microsoft.FSharp.Control.FSharpAsync`1", [unit_type])), ("Item3", FocusState_reflection())], [("Item1", string_type), ("Item2", list_type(TestCase_reflection()))], [("Item1", string_type), ("Item2", list_type(TestCase_reflection()))]]) - - -class TestCase(Union): - def __init__(self, tag: int, *fields: Any) -> None: - super().__init__() - self.tag: int = tag or 0 - self.fields: Array[Any] = list(fields) - - @staticmethod - def cases() -> List[str]: - return ["SyncTest", "AsyncTest", "TestList", "TestListSequential"] - - -TestCase_reflection = _expr10 - -def _expr11() -> TypeInfo: - return record_type("Fable.Pyxpecto.Accuracy", [], Accuracy, lambda: [("absolute", float64_type), ("relative", float64_type)]) - - -@dataclass(eq = False, repr = False) -class Accuracy(Record): - absolute: float - relative: float - -Accuracy_reflection = _expr11 - -AccuracyModule_low: Accuracy = Accuracy(1E-06, 0.001) - -AccuracyModule_medium: Accuracy = Accuracy(1E-08, 1E-05) - -AccuracyModule_high: Accuracy = Accuracy(1E-10, 1E-07) - -AccuracyModule_veryHigh: Accuracy = Accuracy(1E-12, 1E-09) - -def Test_testCase(name: str, body: Callable[[], None]) -> TestCase: - return TestCase(0, name, body, FocusState(0)) - - -def Test_ptestCase(name: str, body: Callable[[], None]) -> TestCase: - return TestCase(0, name, body, FocusState(1)) - - -def Test_ftestCase(name: str, body: Callable[[], None]) -> TestCase: - return TestCase(0, name, body, FocusState(2)) - - -def Test_testCaseAsync(name: str, body: Async[None]) -> TestCase: - return TestCase(1, name, body, FocusState(0)) - - -def Test_ptestCaseAsync(name: str, body: Async[None]) -> TestCase: - return TestCase(1, name, body, FocusState(1)) - - -def Test_ftestCaseAsync(name: str, body: Async[None]) -> TestCase: - return TestCase(1, name, body, FocusState(2)) - - -def Test_testList(name: str, tests: FSharpList[TestCase]) -> TestCase: - return TestCase(2, name, tests) - - -def Test_testSequenced(test: TestCase) -> TestCase: - if test.tag == 1: - name_1: str = test.fields[0] - return TestCase(3, name_1, singleton(TestCase(1, name_1, test.fields[1], test.fields[2]))) - - elif test.tag == 2: - return TestCase(3, test.fields[0], test.fields[1]) - - elif test.tag == 3: - return TestCase(3, test.fields[0], test.fields[1]) - - else: - name: str = test.fields[0] - return TestCase(3, name, singleton(TestCase(0, name, test.fields[1], test.fields[2]))) - - - -def _expr14() -> TypeInfo: - return class_type("Fable.Pyxpecto.Test.TestCaseBuilder", None, Test_TestCaseBuilder) - - -class Test_TestCaseBuilder: - def __init__(self, name: str, focus_state: FocusState) -> None: - self.name: str = name - self.focus_state: FocusState = focus_state - - -Test_TestCaseBuilder_reflection = _expr14 - -def Test_TestCaseBuilder__ctor_Z69FFBD2B(name: str, focus_state: FocusState) -> Test_TestCaseBuilder: - return Test_TestCaseBuilder(name, focus_state) - - -def Test_TestCaseBuilder__Zero(_: Test_TestCaseBuilder) -> None: - pass - - -def Test_TestCaseBuilder__Delay_1505(_: Test_TestCaseBuilder, fn: __G) -> __G: - return fn - - -def Test_TestCaseBuilder__Using_Z3647408D(_: Test_TestCaseBuilder, disposable: __E, fn: Callable[[__E], __F]) -> __F: - return Operators_Using(disposable, fn) - - -def Test_TestCaseBuilder__While_Z4F211AEA(_: Test_TestCaseBuilder, condition: Callable[[], bool], fn: Callable[[], None]) -> None: - while condition(): - fn() - - -def Test_TestCaseBuilder__For_Z371464DD(_: Test_TestCaseBuilder, sequence: IEnumerable_1[__D], fn: Callable[[__D], None]) -> None: - with get_enumerator(sequence) as enumerator: - while enumerator.System_Collections_IEnumerator_MoveNext(): - fn(enumerator.System_Collections_Generic_IEnumerator_1_get_Current()) - - -def Test_TestCaseBuilder__Combine_3A59D1F3(_: Test_TestCaseBuilder, fn1: __C, fn2: Callable[[], None]) -> __C: - fn2() - return fn1 - - -def Test_TestCaseBuilder__TryFinally_33907399(_: Test_TestCaseBuilder, fn: Callable[[], __B], compensation: Callable[[], None]) -> __B: - try: - return fn() - - finally: - compensation() - - - -def Test_TestCaseBuilder__TryWith_Z570AC55B(_: Test_TestCaseBuilder, fn: Callable[[], __A], catch_handler: Callable[[Exception], __A]) -> __A: - try: - return fn() - - except Exception as e: - return catch_handler(e) - - - -def Test_TestCaseBuilder__Run_3A5B6456(_: Test_TestCaseBuilder, fn: Callable[[], None]) -> TestCase: - return TestCase(0, _.name, fn, _.focus_state) - - -def _expr25() -> TypeInfo: - return class_type("Fable.Pyxpecto.Test.TestAsyncBuilder", None, Test_TestAsyncBuilder) - - -class Test_TestAsyncBuilder: - def __init__(self, name: str, focus_state: FocusState) -> None: - self.name: str = name - self.focus_state: FocusState = focus_state - - -Test_TestAsyncBuilder_reflection = _expr25 - -def Test_TestAsyncBuilder__ctor_Z69FFBD2B(name: str, focus_state: FocusState) -> Test_TestAsyncBuilder: - return Test_TestAsyncBuilder(name, focus_state) - - -def Test_TestAsyncBuilder__Zero(_: Test_TestAsyncBuilder) -> Async[None]: - return singleton_1.Zero() - - -def Test_TestAsyncBuilder__Delay_Z5276B41B(_: Test_TestAsyncBuilder, fn: Callable[[], Async[__K]]) -> Async[__K]: - return singleton_1.Delay(fn) - - -def Test_TestAsyncBuilder__Return_1505(_: Test_TestAsyncBuilder, x: __J) -> Async[__J]: - return singleton_1.Return(x) - - -def Test_TestAsyncBuilder__ReturnFrom_ZD4A93B1(_: Test_TestAsyncBuilder, x: Async[__I]) -> Async[__I]: - return singleton_1.ReturnFrom(x) - - -def Test_TestAsyncBuilder__Bind_7A510B33(_: Test_TestAsyncBuilder, computation: Async[__G], fn: Callable[[__G], Async[__H]]) -> Async[__H]: - return singleton_1.Bind(computation, fn) - - -def Test_TestAsyncBuilder__Using_14BA44F9(_: Test_TestAsyncBuilder, disposable: __E, fn: Callable[[__E], Async[__F]]) -> Async[__F]: - return singleton_1.Using(disposable, fn) - - -def Test_TestAsyncBuilder__While_49259930(_: Test_TestAsyncBuilder, condition: Callable[[], bool], fn: Async[None]) -> Async[None]: - return singleton_1.While(condition, fn) - - -def Test_TestAsyncBuilder__For_Z23956591(_: Test_TestAsyncBuilder, sequence: IEnumerable_1[__D], fn: Callable[[__D], Async[None]]) -> Async[None]: - return singleton_1.For(sequence, fn) - - -def Test_TestAsyncBuilder__Combine_Z3AE9B5C1(_: Test_TestAsyncBuilder, fn1: Async[None], fn2: Async[__C]) -> Async[__C]: - return singleton_1.Combine(fn1, fn2) - - -def Test_TestAsyncBuilder__TryFinally_73399279(_: Test_TestAsyncBuilder, fn: Async[__B], compensation: Callable[[], None]) -> Async[__B]: - return singleton_1.TryFinally(fn, compensation) - - -def Test_TestAsyncBuilder__TryWith_48476DCF(_: Test_TestAsyncBuilder, fn: Async[__A], catch_handler: Callable[[Exception], Async[__A]]) -> Async[__A]: - return singleton_1.TryWith(fn, catch_handler) - - -def Test_TestAsyncBuilder__Run_Z3C5FE790(_: Test_TestAsyncBuilder, fn: Async[None]) -> TestCase: - return TestCase(1, _.name, fn, _.focus_state) - - -def Test_failtest(msg: str) -> Any: - raise Exception(msg) - - -def Test_failtestf(fmt: Any, msg: __A) -> __B: - return to_fail(fmt)(msg) - - -def Expect_notEqual(actual: __A, expected: __A, msg: str) -> None: - assert_not_equal(actual, expected, msg) - - -def Expect_isNull_0027(cond: Optional[Any]=None) -> bool: - if equals(cond, None): - return True - - else: - return False - - - -def Expect_isNull(cond: Optional[Any]=None) -> Callable[[str], None]: - actual: bool = Expect_isNull_0027(cond) - def _arrow30(msg: str, cond: __A=cond) -> None: - actual_1: bool = actual - msg_1: str = msg - if actual_1 == True: - assert_equal(actual_1, True, msg_1) - - else: - raise Exception((((((((((((((" Expected: " + ('\033[96m')) + "") + str(True)) + "") + ('\033[0m')) + " \n\b Actual: ") + ('\033[91m')) + "") + str(actual_1)) + "") + ('\033[0m')) + " \n\b Message: ") + msg_1) + "") - - - return _arrow30 - - -def Expect_isNotNull(cond: Optional[Any]=None) -> Callable[[str], None]: - actual: bool = Expect_isNull_0027(cond) - def _arrow31(msg: str, cond: __A=cond) -> None: - Expect_notEqual(actual, True, msg) - - return _arrow31 - - -def Expect_isNotNaN(cond: float, msg: str) -> None: - if isnan(cond): - raise Exception(msg) - - - -def Expect_isNotInfinity(cond: float, msg: str) -> None: - if isinf(cond): - raise Exception(msg) - - - -def Expect_isTrue(cond: bool) -> Callable[[str], None]: - def _arrow32(msg: str, cond: bool=cond) -> None: - actual: bool = cond - msg_1: str = msg - if actual == True: - assert_equal(actual, True, msg_1) - - else: - raise Exception((((((((((((((" Expected: " + ('\033[96m')) + "") + str(True)) + "") + ('\033[0m')) + " \n\b Actual: ") + ('\033[91m')) + "") + str(actual)) + "") + ('\033[0m')) + " \n\b Message: ") + msg_1) + "") - - - return _arrow32 - - -def Expect_isFalse(cond: bool) -> Callable[[str], None]: - def _arrow34(msg: str, cond: bool=cond) -> None: - actual: bool = cond - msg_1: str = msg - if actual == False: - assert_equal(actual, False, msg_1) - - else: - raise Exception((((((((((((((" Expected: " + ('\033[96m')) + "") + str(False)) + "") + ('\033[0m')) + " \n\b Actual: ") + ('\033[91m')) + "") + str(actual)) + "") + ('\033[0m')) + " \n\b Message: ") + msg_1) + "") - - - return _arrow34 - - -def Expect_isZero(cond: int) -> Callable[[str], None]: - def _arrow35(msg: str, cond: int=cond) -> None: - actual: int = cond or 0 - msg_1: str = msg - if actual == 0: - assert_equal(actual, 0, msg_1) - - else: - raise Exception((((((((((((((" Expected: " + ('\033[96m')) + "") + str(0)) + "") + ('\033[0m')) + " \n\b Actual: ") + ('\033[91m')) + "") + str(actual)) + "") + ('\033[0m')) + " \n\b Message: ") + msg_1) + "") - - - return _arrow35 - - -def Expect_isEmpty(x: IEnumerable_1[Any], msg: str) -> None: - if not is_empty(x): - to_fail(printf("%s. Should be empty."))(msg) - - - -def Expect_pass(__unit: None=None) -> None: - assert_equal(True, True, "The test passed") - - -def Expect_passWithMsg(message: str) -> None: - msg: str = message - assert_equal(True, True, msg) - - -def Expect_exists(x: IEnumerable_1[_A], a: Callable[[_A], bool], msg: str) -> None: - if not exists(a, x): - raise Exception(msg) - - - -def Expect_all(x: IEnumerable_1[_A], a: Callable[[_A], bool], msg: str) -> None: - if not for_all(a, x): - raise Exception(msg) - - - -def Expect_isNonEmpty(x: IEnumerable_1[Any], msg: str) -> None: - if is_empty(x): - to_fail(printf("%s. Should not be empty."))(msg) - - - -def Expect_isNotEmpty(x: IEnumerable_1[Any], msg: str) -> None: - Expect_isNotNull(x)(msg) - Expect_isNonEmpty(x, msg) - - -def Expect_hasLength(x: IEnumerable_1[Any], number: int, msg: str) -> None: - actual: int = length(x) or 0 - expected: int = number or 0 - msg_1: str = to_text(printf("%s. Expected %A to have length %i"))(msg)(x)(number) - if actual == expected: - assert_equal(actual, expected, msg_1) - - else: - raise Exception((((((((((((((" Expected: " + ('\033[96m')) + "") + str(expected)) + "") + ('\033[0m')) + " \n\b Actual: ") + ('\033[91m')) + "") + str(actual)) + "") + ('\033[0m')) + " \n\b Message: ") + msg_1) + "") - - - -def Expect_isOk(x: FSharpResult_2[Any, Any], message: str) -> None: - if x.tag == 1: - to_fail(printf("%s. Expected Ok, was Error(\"%A\")."))(message)(x.fields[0]) - - else: - Expect_passWithMsg(message) - - - -def Expect_wantOk(x: FSharpResult_2[__A, Any], message: str) -> __A: - if x.tag == 1: - return to_fail(printf("%s. Expected Ok, was Error(\"%A\")."))(message)(x.fields[0]) - - else: - Expect_passWithMsg(message) - return x.fields[0] - - - -def Expect_stringContains(subject: str, substring: str, message: str) -> None: - if not (subject.find(substring) >= 0): - to_fail(printf("%s. Expected subject string \'%s\' to contain substring \'%s\'."))(message)(subject)(substring) - - else: - Expect_passWithMsg(message) - - - -def Expect_isError(x: FSharpResult_2[Any, Any], message: str) -> None: - if x.tag == 0: - to_fail(printf("%s. Expected Error _, was Ok(%A)."))(message)(x.fields[0]) - - else: - Expect_passWithMsg(message) - - - -def Expect_isSome(x: Optional[__A], message: str) -> None: - if x is None: - to_fail(printf("%s. Expected Some _, was None."))(message) - - else: - Expect_passWithMsg(message) - - - -def Expect_wantSome(x: Optional[__A], message: str) -> __A: - if x is None: - return to_fail(printf("%s. Expected Some _, was None."))(message) - - else: - x_0027: __A = value_2(x) - Expect_passWithMsg(message) - return x_0027 - - - -def Expect_wantError(x: FSharpResult_2[Any, _B], message: str) -> _B: - if x.tag == 0: - return to_fail(printf("%s. Expected Error _, was Ok(%A)."))(message)(x.fields[0]) - - else: - Expect_passWithMsg(message) - return x.fields[0] - - - -def Expect_isNone(x: Optional[__A], message: str) -> None: - if x is not None: - x_0027: __A = value_2(x) - to_fail(printf("%s. Expected None, was Some(%A)."))(message)(x_0027) - - else: - Expect_passWithMsg(message) - - - -def Expect_throws_0027(f: Callable[[], None]) -> Optional[Exception]: - try: - f() - return None - - except Exception as exn: - return exn - - - -def Expect_throws(f: Callable[[], None], msg: str) -> None: - match_value: Optional[Exception] = Expect_throws_0027(f) - if match_value is not None: - pass - - else: - to_fail(printf("%s. Expected f to throw."))(msg) - - - -def Expect_throwsC(f: Callable[[], None], cont: Callable[[Exception], __A]) -> __A: - match_value: Optional[Exception] = Expect_throws_0027(f) - if match_value is not None: - return cont(match_value) - - else: - return to_fail(printf("Expected f to throw.")) - - - -def Expect_containsAll(actual: IEnumerable_1[__A], expected: IEnumerable_1[__A], message: str) -> None: - matchValue: FSharpList[__A] = of_seq(actual) - expected_els: FSharpList[__A] = of_seq(expected) - actual_els: FSharpList[__A] = matchValue - def predicate(a: Optional[__A]=None, actual: IEnumerable_1[Any]=actual, expected: IEnumerable_1[Any]=expected, message: str=message) -> bool: - class ObjectExpr55: - @property - def Equals(self) -> Callable[[__A_, __A_], bool]: - return equals - - @property - def GetHashCode(self) -> Callable[[__A_], int]: - return structural_hash - - return contains(a, expected_els, ObjectExpr55()) - - matching_els: FSharpList[__A] = filter(predicate, actual_els) - def predicate_1(a_1: Optional[__A]=None, actual: IEnumerable_1[Any]=actual, expected: IEnumerable_1[Any]=expected, message: str=message) -> bool: - class ObjectExpr56: - @property - def Equals(self) -> Callable[[__A_, __A_], bool]: - return equals - - @property - def GetHashCode(self) -> Callable[[__A_], int]: - return structural_hash - - return not contains(a_1, matching_els, ObjectExpr56()) - - extra_els: FSharpList[__A] = filter(predicate_1, actual_els) - def predicate_2(e: Optional[__A]=None, actual: IEnumerable_1[Any]=actual, expected: IEnumerable_1[Any]=expected, message: str=message) -> bool: - class ObjectExpr57: - @property - def Equals(self) -> Callable[[__A_, __A_], bool]: - return equals - - @property - def GetHashCode(self) -> Callable[[__A_], int]: - return structural_hash - - return not contains(e, matching_els, ObjectExpr57()) - - missing_els: FSharpList[__A] = filter(predicate_2, expected_els) - if is_empty_1(missing_els): - pass - - else: - Test_failtest(to_text(printf("%s. Sequence `actual` does not contain all `expected` elements. Missing elements from `actual`: %A. Extra elements in `actual`: %A"))(message)(missing_els)(extra_els)) - - - -def Expect_floatClose(accuracy: Accuracy, actual: float, expected: float, message: str) -> None: - if isinf(actual): - Test_failtestf(printf("%s. Expected actual to not be infinity, but it was."), message) - - elif isinf(expected): - Test_failtestf(printf("%s. Expected expected to not be infinity, but it was."), message) - - else: - def _arrow59(__unit: None=None, accuracy: Accuracy=accuracy, actual: float=actual, expected: float=expected, message: str=message) -> bool: - a: float = actual - b: float = expected - def _arrow58(__unit: None=None) -> float: - m_1: Accuracy = accuracy - return m_1.absolute + (m_1.relative * max(compare_primitives, abs(a), abs(b))) - - return abs(a - b) <= _arrow58() - - if not _arrow59(): - arg: float - m_2: Accuracy = accuracy - def _arrow60(x_1: float, y_1: float, accuracy: Accuracy=accuracy, actual: float=actual, expected: float=expected, message: str=message) -> int: - return compare_primitives(x_1, y_1) - - arg = m_2.absolute + (m_2.relative * max(_arrow60, abs(actual), abs(expected))) - arg_3: float = abs(actual - expected) - Test_failtestf(printf("%s. Expected difference to be less than %.20g for accuracy {absolute=%.20g; relative=%.20g}, but was %.20g. actual=%.20g expected=%.20g"), message)(arg)(accuracy.absolute)(accuracy.relative)(arg_3)(actual)(expected) - - - - -def Expect_floatLessThanOrClose(accuracy: Accuracy, actual: float, expected: float, message: str) -> None: - if actual > expected: - Expect_floatClose(accuracy, actual, expected, message) - - - -def Expect_floatGreaterThanOrClose(accuracy: Accuracy, actual: float, expected: float, message: str) -> None: - if actual < expected: - Expect_floatClose(accuracy, actual, expected, message) - - - -def Pyxpecto_isFocused(test: TestCase) -> bool: - (pattern_matching_result, tests, tests_1) = (None, None, None) - if test.tag == 1: - if test.fields[2].tag == 2: - pattern_matching_result = 1 - - else: - pattern_matching_result = 4 - - - elif test.tag == 2: - pattern_matching_result = 2 - tests = test.fields[1] - - elif test.tag == 3: - pattern_matching_result = 3 - tests_1 = test.fields[1] - - elif test.fields[2].tag == 2: - pattern_matching_result = 0 - - else: - pattern_matching_result = 4 - - if pattern_matching_result == 0: - return True - - elif pattern_matching_result == 1: - return True - - elif pattern_matching_result == 2: - def _arrow68(test_1: TestCase, test: TestCase=test) -> bool: - return Pyxpecto_isFocused(test_1) - - return exists_1(_arrow68, tests) - - elif pattern_matching_result == 3: - def _arrow70(test_2: TestCase, test: TestCase=test) -> bool: - return Pyxpecto_isFocused(test_2) - - return exists_1(_arrow70, tests_1) - - elif pattern_matching_result == 4: - return False - - - -def Pyxpecto_flattenTests(last_name: str, _arg: TestCase) -> FSharpList[TestCase]: - if _arg.tag == 1: - name_1: str = _arg.fields[0] - return singleton(TestCase(1, name_1 if is_null_or_white_space(last_name) else to_text(printf("%s - %s"))(last_name)(name_1), _arg.fields[1], _arg.fields[2])) - - elif _arg.tag == 2: - def _arrow73(__unit: None=None, last_name: str=last_name, _arg: TestCase=_arg) -> IEnumerable_1[TestCase]: - def _arrow72(test_2: TestCase) -> IEnumerable_1[TestCase]: - return Pyxpecto_flattenTests(_arg.fields[0], test_2) - - return collect(_arrow72, _arg.fields[1]) - - return to_list(delay(_arrow73)) - - elif _arg.tag == 3: - def _arrow75(__unit: None=None, last_name: str=last_name, _arg: TestCase=_arg) -> IEnumerable_1[TestCase]: - def _arrow74(test_3: TestCase) -> IEnumerable_1[TestCase]: - return Pyxpecto_flattenTests(_arg.fields[0], test_3) - - return collect(_arrow74, _arg.fields[1]) - - return to_list(delay(_arrow75)) - - else: - name: str = _arg.fields[0] - return singleton(TestCase(0, name if is_null_or_white_space(last_name) else to_text(printf("%s - %s"))(last_name)(name), _arg.fields[1], _arg.fields[2])) - - - -def Pyxpecto_checkFocused(test: TestCase) -> bool: - has_focused: bool = False - def loop(_arg: TestCase, test: TestCase=test) -> None: - nonlocal has_focused - (pattern_matching_result, tests) = (None, None) - if _arg.tag == 0: - if _arg.fields[2].tag == 2: - pattern_matching_result = 0 - - else: - pattern_matching_result = 1 - - - elif _arg.tag == 3: - pattern_matching_result = 2 - tests = _arg.fields[1] - - elif _arg.tag == 2: - pattern_matching_result = 2 - tests = _arg.fields[1] - - elif _arg.fields[2].tag == 2: - pattern_matching_result = 0 - - else: - pattern_matching_result = 1 - - if pattern_matching_result == 0: - has_focused = True - - elif pattern_matching_result == 1: - pass - - elif pattern_matching_result == 2: - with get_enumerator(tests) as enumerator: - while enumerator.System_Collections_IEnumerator_MoveNext(): - loop(enumerator.System_Collections_Generic_IEnumerator_1_get_Current()) - - - loop(test) - return has_focused - - -Pyxpecto_PyBindings_cmd_args: Array[str] = sys.argv - -def _expr113() -> TypeInfo: - return class_type("Fable.Pyxpecto.Pyxpecto.CustomTestRunner", None, Pyxpecto_CustomTestRunner) - - -class Pyxpecto_CustomTestRunner: - def __init__(self, test: TestCase) -> None: - has_focused: bool = Pyxpecto_checkFocused(test) - verify_focused_allowed: None - class ObjectExpr112: - @property - def Equals(self) -> Callable[[str, str], bool]: - def _arrow111(x: str, y: str) -> bool: - return x == y - - return _arrow111 - - @property - def GetHashCode(self) -> Callable[[str], int]: - return string_hash - - if has_focused if contains_1("--fail-on-focused-tests", Pyxpecto_PyBindings_cmd_args, ObjectExpr112()) else False: - raise Exception(((((("" + ('\033[91m')) + "Cannot run focused tests with \'") + "--fail-on-focused-tests") + "\' commandline arg.") + ('\033[0m')) + "") - - else: - verify_focused_allowed = None - - self._SuccessfulTests: int = 0 - self._FailedTests: int = 0 - self._IgnoredTests: int = 0 - self._HasFocused: bool = has_focused - - def print_success_msg(self, name: str) -> None: - this: Pyxpecto_CustomTestRunner = self - to_console(((("" + ("💎 | " if this.HasFocused else "")) + "✔️ ") + name) + "") - - def print_error_msg(self, name: str, msg: str) -> None: - this: Pyxpecto_CustomTestRunner = self - to_console(((((("" + ("💎 | " if this.HasFocused else "")) + "❌ ") + name) + "\n\b") + msg) + "") - - def print_skip_pending_msg(self, name: str) -> None: - to_console(printf("🚧 skipping \'%s\' due to it being marked as pending"))(name) - - @property - def SuccessfulTests(self, __unit: None=None) -> int: - __: Pyxpecto_CustomTestRunner = self - return __._SuccessfulTests - - @SuccessfulTests.setter - def SuccessfulTests(self, v: int) -> None: - __: Pyxpecto_CustomTestRunner = self - __._SuccessfulTests = v or 0 - - @property - def FailedTests(self, __unit: None=None) -> int: - __: Pyxpecto_CustomTestRunner = self - return __._FailedTests - - @FailedTests.setter - def FailedTests(self, v: int) -> None: - __: Pyxpecto_CustomTestRunner = self - __._FailedTests = v or 0 - - @property - def IgnoredTests(self, __unit: None=None) -> int: - __: Pyxpecto_CustomTestRunner = self - return __._IgnoredTests - - @IgnoredTests.setter - def IgnoredTests(self, v: int) -> None: - __: Pyxpecto_CustomTestRunner = self - __._IgnoredTests = v or 0 - - @property - def HasFocused(self, __unit: None=None) -> bool: - __: Pyxpecto_CustomTestRunner = self - return __._HasFocused - - @property - def SumTests(self, __unit: None=None) -> int: - this: Pyxpecto_CustomTestRunner = self - return this.SuccessfulTests + this.FailedTests - - def RunSyncTest(self, name: str, body: Callable[[], None]) -> None: - this: Pyxpecto_CustomTestRunner = self - try: - body() - this.SuccessfulTests = (this.SuccessfulTests + 1) or 0 - this.print_success_msg(name) - - except Exception as e: - this.FailedTests = (this.FailedTests + 1) or 0 - arg_1: str = str(e) - this.print_error_msg(name, arg_1) - - - def RunAsyncTest(self, name: str, body: Async[None]) -> None: - this: Pyxpecto_CustomTestRunner = self - try: - def _arrow110(__unit: None=None) -> Async[None]: - def _arrow109(__unit: None=None) -> Async[None]: - this.SuccessfulTests = (this.SuccessfulTests + 1) or 0 - this.print_success_msg(name) - return singleton_1.Zero() - - return singleton_1.Bind(body, _arrow109) - - run_synchronously(singleton_1.Delay(_arrow110)) - - except Exception as e: - this.FailedTests = (this.FailedTests + 1) or 0 - arg_2: str = str(e) - this.print_error_msg(name, arg_2) - - - def SkipPendingTest(self, name: str) -> None: - this: Pyxpecto_CustomTestRunner = self - this.IgnoredTests = (this.IgnoredTests + 1) or 0 - this.print_skip_pending_msg(name) - - def SkipUnfocusedTest(self, __unit: None=None) -> None: - this: Pyxpecto_CustomTestRunner = self - this.IgnoredTests = (this.IgnoredTests + 1) or 0 - - -Pyxpecto_CustomTestRunner_reflection = _expr113 - -def Pyxpecto_CustomTestRunner__ctor_Z1F0D1F49(test: TestCase) -> Pyxpecto_CustomTestRunner: - return Pyxpecto_CustomTestRunner(test) - - -def Pyxpecto_runViaPy(test: TestCase) -> int: - runner: Pyxpecto_CustomTestRunner = Pyxpecto_CustomTestRunner(test) - def run(runner_1: Pyxpecto_CustomTestRunner, test_1: TestCase, test: TestCase=test) -> None: - (pattern_matching_result, name_2, test_cases) = (None, None, None) - if test_1.tag == 1: - pattern_matching_result = 1 - - elif test_1.tag == 3: - pattern_matching_result = 2 - name_2 = test_1.fields[0] - test_cases = test_1.fields[1] - - elif test_1.tag == 2: - pattern_matching_result = 2 - name_2 = test_1.fields[0] - test_cases = test_1.fields[1] - - else: - pattern_matching_result = 0 - - if pattern_matching_result == 0: - test_2: Callable[[], None] = test_1.fields[1] - name: str = test_1.fields[0] - focus: FocusState = test_1.fields[2] - matchValue: bool = runner_1.HasFocused - (pattern_matching_result_1,) = (None,) - if matchValue: - if focus.tag == 2: - pattern_matching_result_1 = 2 - - else: - pattern_matching_result_1 = 3 - - - elif focus.tag == 0: - pattern_matching_result_1 = 0 - - elif focus.tag == 1: - pattern_matching_result_1 = 1 - - else: - pattern_matching_result_1 = 3 - - if pattern_matching_result_1 == 0: - runner_1.RunSyncTest(name, test_2) - - elif pattern_matching_result_1 == 1: - runner_1.SkipPendingTest(name) - - elif pattern_matching_result_1 == 2: - runner_1.RunSyncTest(name, test_2) - - elif pattern_matching_result_1 == 3: - runner_1.SkipUnfocusedTest() - - - elif pattern_matching_result == 1: - test_3: Async[None] = test_1.fields[1] - name_1: str = test_1.fields[0] - focus_1: FocusState = test_1.fields[2] - matchValue_1: bool = runner_1.HasFocused - (pattern_matching_result_2,) = (None,) - if matchValue_1: - if focus_1.tag == 2: - pattern_matching_result_2 = 2 - - else: - pattern_matching_result_2 = 3 - - - elif focus_1.tag == 0: - pattern_matching_result_2 = 0 - - elif focus_1.tag == 1: - pattern_matching_result_2 = 1 - - else: - pattern_matching_result_2 = 3 - - if pattern_matching_result_2 == 0: - runner_1.RunAsyncTest(name_1, test_3) - - elif pattern_matching_result_2 == 1: - runner_1.SkipPendingTest(name_1) - - elif pattern_matching_result_2 == 2: - runner_1.RunAsyncTest(name_1, test_3) - - elif pattern_matching_result_2 == 3: - runner_1.SkipUnfocusedTest() - - - elif pattern_matching_result == 2: - def mapping(t: TestCase, runner_1: Pyxpecto_CustomTestRunner=runner_1, test_1: TestCase=test_1) -> FSharpList[TestCase]: - return Pyxpecto_flattenTests(name_2, t) - - list_2: FSharpList[TestCase] = collect_1(mapping, test_cases) - iterate(curry2(run)(runner_1), list_2) - - - to_console(printf("🚀 start running tests ...")) - run(runner, test) - inner_msg_string: str = ((((((((((((((((((((((("" + ('\033[36m')) + "") + str(runner.SumTests)) + "") + ('\033[0m')) + " tests run - ") + ('\033[92m')) + "") + str(runner.SuccessfulTests)) + "") + ('\033[0m')) + " passed, ") + ('\033[36m')) + "") + str(runner.IgnoredTests)) + "") + ('\033[0m')) + " ignored, ") + ('\033[91m')) + "") + str(runner.FailedTests)) + "") + ('\033[0m')) + " failed" - msg: str = to_string(StringBuilder__AppendLine_Z721C83C5(StringBuilder__AppendLine_Z721C83C5(StringBuilder__AppendLine_Z721C83C5(StringBuilder__ctor(), "-------------------------------------------------------------------------------"), inner_msg_string), "-------------------------------------------------------------------------------")) - to_console(printf("%s"))(msg) - match_value_2: int = runner.FailedTests or 0 - if match_value_2 == 1: - to_console(((((("" + ('\033[91m')) + "") + str(runner.FailedTests)) + " test failed!") + ('\033[0m')) + "") - return 1 - - elif match_value_2 > 1: - to_console(((((("" + ('\033[91m')) + "") + str(match_value_2)) + " tests failed!") + ('\033[0m')) + "") - return 1 - - else: - to_console(((("" + ('\033[92m')) + "Success!") + ('\033[0m')) + "") - return 0 - - - -def Pyxpecto_runViaDotnet(test: TestCase) -> int: - raise Exception("Currently not implemented, use Expecto for now.") - return 1 - - -def Pyxpecto_runTests(test: TestCase) -> int: - return Pyxpecto_runViaPy(test) - -