Coder Social home page Coder Social logo

gedaiu / fluent-asserts Goto Github PK

View Code? Open in Web Editor NEW
43.0 3.0 5.0 507 KB

DLang fluent assertions done right

Home Page: http://fluentasserts.szabobogdan.com/

License: MIT License

D 99.71% Shell 0.29%
vibe-d testing asserts tdd bdd-style dlang fluent-assertions

fluent-asserts's Introduction

Line Coverage DUB Version DUB Installs

Writing unit tests is easy with Dlang. The unittest block allows you to start writing tests and to be productive with no special setup.

Unfortunately the assert expression does not help you to write expressive asserts, and in case of a failure it's hard to find why an assert failed. The fluent-asserts library allows you to more naturally specify the expected outcome of a TDD or BDD-style test.

To begin

  1. Add the DUB dependency: https://code.dlang.org/packages/fluent-asserts
$ dub add fluent-asserts
  1. Use it:
    unittest {
        true.should.equal(false).because("this is a failing assert");
    }

    unittest {
        Assert.equal(true, false, "this is a failing assert");
    }
  1. Run the tests:
➜  dub test --compiler=ldc2

asciicast

API Docs

The library provides the expect, should templates and the Assert struct.

Expect

expect is the main assert function exposed by this library. It takes a parameter which is the value that is tested. You can use any assert operation provided by the base library or any other operations that was registered by a third party library.

Expect expect(T)(lazy T testedValue, ...);
Expect expect(void delegate() callable, ...);
...

expect(testedValue).to.equal(42);

In addition, the library provides the not and because modifiers that allow to improve your asserts.

not negates the assert condition:

expect(testedValue).to.not.equal(42);

because allows you to add a custom message:

    expect(true).to.equal(false).because("of test reasons");
    /// will output this message: Because of test reasons, true should equal `false`.

Should

should is designed to be used in combination with Uniform Function Call Syntax (UFCS), and is an alias for expect.

    auto should(T)(lazy T testData, ...);

So the following statements are equivalent

testedValue.should.equal(42);
expect(testedValue).to.equal(42);

In addition, you can use not and because modifiers with should.

not negates the assert condition:

    testedValue.should.not.equal(42);
    true.should.equal(false).because("of test reasons");

Assert

Assert is a wrapper for the expect function, that allows you to use the asserts with a different syntax.

For example, the following lines are equivalent:

    expect(testedValue).to.equal(42);
    Assert.equal(testedValue, 42);

All the asserts that are available using the expect syntax are available with Assert. If you want to negate the check, just add not before the assert name:

    Assert.notEqual(testedValue, 42);

Built in operations

Extend the library

Registering new operations

Even though this library has an extensive set of operations, sometimes a new operation might be needed to test your code. Operations are functions that recieve an Evaluation and returns an IResult list in case there was a failure. You can check any of the built in operations for a refference implementation.

IResult[] customOperation(ref Evaluation evaluation) @safe nothrow {
    ...
}

Once the operation is ready to use, it has to be registered with the global registry:

static this() {
    /// bind the type to different matchers
    Registry.instance.register!(SysTime, SysTime)("between", &customOperation);
    Registry.instance.register!(SysTime, SysTime)("within", &customOperation);

    /// or use * to match any type
    Registry.instance.register("*", "*", "customOperation", &customOperation);
}

Registering new serializers

In order to setup an Evaluation, the actual and expected values need to be converted to a string. Most of the time, the default serializer will do a great job, but sometimes you might want to add a custom serializer for your types.

static this() {
    SerializerRegistry.instance.register(&jsonToString);
}

string jsonToString(Json value) {
    /// you can add here your custom serializer for Jsons
}

License

MIT. See LICENSE for details.

fluent-asserts's People

Contributors

benjaminschaaf avatar gedaiu avatar gizmomogwai avatar nilsding avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

fluent-asserts's Issues

why the stack trace removed ? can we add it back?

Hi,

When an assertion fails, I want to see the stack trace, esp. in a multi-threaded program, I saw this commit: stack trace is added, and then removed:

f1735bf

I wonder why? can we add it back? It will greatly help debug the program.

Or provide a config option to let the user decide if s/he want to see the full stack trace? (I think most people want to see it).

Thanks.

Compilation fails for arrays of structs/classes with member functions

Test case:

unittest {
	struct S {
		void f() {}
	}
	[S()].should.equal([S()]);
}

Fails with:

/usr/include/dlang/dmd/object.d(3756,5): Error: static assert  "Cannot implicitly convert type S to immutable in idup."
../../../.dub/packages/fluent-asserts-0.6.5/fluent-asserts/core/fluentasserts/core/array.d(20,35):        instantiated from here: idup!(S)
../../../.dub/packages/fluent-asserts-0.6.5/fluent-asserts/core/fluentasserts/core/array.d(194,39):        instantiated from here: __ctor!(S[], const(S)[])
../../../.dub/packages/fluent-asserts-0.6.5/fluent-asserts/core/fluentasserts/core/base.d(263,14):        instantiated from here: ShouldList!(S[])
fatestcase.d(16,6):        instantiated from here: should!(S[])

Same for classes:

unittest {
	class C {
		void f() {}
	}
	[new C()].should.equal([new C()]);
}

Which fails with:

/usr/include/dlang/dmd/std/format.d(3460,13): Error: template instance std.format.formatObject!(Appender!string, const(S), char) does not match template declaration formatObject(Writer, T, Char)(ref Writer w, ref T val, ref const FormatSpec!Char f) if (hasToString!(T, Char))
/usr/include/dlang/dmd/std/format.d(3190,16): Error: template instance std.format.formatValue!(Appender!string, const(S), char) error instantiating
/usr/include/dlang/dmd/std/format.d(2969,30):        instantiated from here: formatElement!(Appender!string, const(S), char)
/usr/include/dlang/dmd/std/format.d(2671,20):        instantiated from here: formatRange!(Appender!string, const(S)[], char)
/usr/include/dlang/dmd/std/conv.d(137,24):        instantiated from here: formatValue!(Appender!string, const(S)[], char)
/usr/include/dlang/dmd/std/conv.d(974,23):        ... (3 instantiations, -v to show) ...
../../../.dub/packages/fluent-asserts-0.6.5/fluent-asserts/core/fluentasserts/core/base.d(263,14):        instantiated from here: ShouldList!(S[])
fatestcase.d(16,11):        instantiated from here: should!(S[])
/usr/include/dlang/dmd/object.d(3756,5): Error: static assert  "Cannot implicitly convert type S to immutable in idup."
../../../.dub/packages/fluent-asserts-0.6.5/fluent-asserts/core/fluentasserts/core/array.d(20,35):        instantiated from here: idup!(S)
../../../.dub/packages/fluent-asserts-0.6.5/fluent-asserts/core/fluentasserts/core/array.d(194,39):        instantiated from here: __ctor!(S[], const(S)[])
../../../.dub/packages/fluent-asserts-0.6.5/fluent-asserts/core/fluentasserts/core/base.d(263,14):        instantiated from here: ShouldList!(S[])
fatestcase.d(16,11):        instantiated from here: should!(S[])

I tested it with:

$ dmd --version 
DMD64 D Compiler v2.075.0
Copyright (c) 1999-2017 by Digital Mars written by Walter Bright
$ ldc2 --version
LDC - the LLVM D compiler (1.3.0):
  based on DMD v2.073.2 and LLVM 4.0.0
  built with LDC - the LLVM D compiler (1.3.0)
  Default target: x86_64-unknown-linux-gnu
  Host CPU: silvermont
$ gdc --version 
gdc (gdcproject.org 20161225-v2.068.2_gcc4.8) 4.8.5

Also, looks like it happens only if struct/class is defined inside unittest block. I discovered this issue when worked on my code, but in my code struct is defined outside unittest block and it still fails.
So, I am not sure that this is fluent-asserts' bug, probably this is the bug in compiler.

UPD: So, it isn't a bug in the compiler

Comparing const array of classes gives compile error

Referencing fluent-asserts 0.12.2:

import fluent.asserts;

class A{}

unittest
{
    A a = new A();
    const(A)[] arr = [a];
    arr.should.equal([a]); 
}   

fails with compiler error

/usr/include/dmd/druntime/import/object.d(4235,5): Error: static assert:  "Cannot implicitly convert type A to immutable in idup."
../../.dub/packages/fluent-asserts-0.12.2/fluent-asserts/source/fluentasserts/core/array.d(20,35):        instantiated from here: idup!(A)
../../.dub/packages/fluent-asserts-0.12.2/fluent-asserts/source/fluentasserts/core/array.d(186,34):        instantiated from here: toValueList!(const(A), A[])
source/test.d(12,21):        instantiated from here: equal!(A[])
/usr/bin/dmd failed with exit code 1.

If I replace A with a struct (and don't new it), the assert works. This test compiled with fluent-asserts 0.5.0 (and a full-fledged version passed in my project). If required, I can do some more advanced digging to find the exact version in which this regression was introduced.

Move vibe.d support to a separate package

Currently when using fluent-asserts, vibe.d is always pulled in as a dependency. This is very undesirable for projects which do not use vibe.d by themselves because it massively increases build times.

As a solution, I propose to move the vibe.d support of fluent-asserts to a separate package (fluent-assets-vibe-d) which itself depends on fluent-asserts. Projects which don't need the vibe.d support could then simply use the basic fluent-asserts package and projects which need the vibe.d support would use fluent-assets-vibe-d.

null strings assertion error

message.data.should.equal("some data")

Diff:some data

 Expected:some᛫data
   Actual:some᛫data

when

message = [115, 111, 109, 101, 32, 100, 97, 116, 97, 0, 0].assumeUTF

A way to include more data in an assertion.

When you have a test that needs to run multiple times, or simply includes an iteration of some sort, it is often useful to know at which iteration an assertion failed. Currently the only way to include that data with because:

unittest {
    foreach(i; 0..100) {
        ...

        result.should.equal(expected).because("At iteration %s".format(i));
    }
}

It would be nice if there was a simple way of including arbitrary data along with an exception, maybe something like this:

result.should.equal(expected).with(i);

----------------------
TestException: result should equal expected.
i = 5

Expected: ...

Or perhaps a middle-ground would be to allow because to be used like format:

result.should.equal(expected).because("At iteration %s", i);

improve the exception proxy usability

.should.throwException!URIParseException.withMessage.equal("Can not parse the URI authority");

.should.throwException!URIParseException.withMessage("Can not parse the URI authority");

should.containOnly and should.equal fail on a range of ranges

void main()
{
import std.algorithm : equal, map;
import fluent.asserts : should;
import std.range : iota, array;

auto ror = iota(1,4).map!iota;
assert(ror.equal!equal([[0],[0,1],[0,1,2]]));

// These slowly use up all available memory:
// ror.should.equal(([[0],[0,1],[0,1,2]]));
// ror.should.containOnly(([[0],[0,1],[0,1,2]]));

// However, these work:
ror.map!array.should.containOnly([[0],[0,1],[0,1,2]]);
ror.map!array.should.equal([[0],[0,1],[0,1,2]]);
}

`equal` for ranges compile errors

equal() called for InputRange fails on compilation
This code:

struct Range {
	int n;
	int front() {
		return n;
	}
	void popFront() {
		++n;
	}
	bool empty() {
		return n == 3;
	}
}

auto r = Range();
r.should.equal([0,1,2]);

Fails:

core/fluentasserts/core/array.d(25,49): Error: no property 'length' for type 'Range'
core/fluentasserts/core/array.d(28,55): Error: no [] operator overload for type Range
equalforranges.d(32,16): Error: template instance fluentasserts.core.array.ShouldList!(Range).ShouldList.equal!int error instantiating

But it sucessfully compiles, if I use array function from std.array:

r.array.should.equal([0,1,2]);

What about new overload of equal() for ranges? std.range.primitives can help with it.
This function could just convert range to array (if range is not infinite, of course) and pass it to existing function.

make vibe dependency optional

As you already separated it into :vibe it is optional already, but it could have been kept in the normal package and just adding "optional": true and then using version (Have_vibe_data) version (Have_vibe_http)

Don't know if you want to change the layout again, but maybe worth considering for 1.0.0. Close if you don't want to do this

Deprecation of `this` as a Type

Since DMD v2.083.1, a large number of compilation warnings in the format below have been observed:

../../.dub/packages/fluent-asserts-0.9.0/fluent-asserts/core/fluentasserts/core/basetype.d(22,17): Deprecation: Using this as a type is deprecated. Use typeof(this) instead

`agent3.allow.should.containOnly([ ]);` does not work

../../.dub/packages/fluent-asserts-0.8.5/fluent-asserts/core/fluentasserts/core/array.d(16,29): Error: template std.array.array cannot deduce function from argument types !()(void[]), candidates are:
/Library/D/dmd/src/phobos/std/array.d(98,21):        std.array.array(Range)(Range r) if (isIterable!Range && !isNarrowString!Range && !isInfinite!Range)
/Library/D/dmd/src/phobos/std/array.d(143,37):        std.array.array(Range)(Range r) if (isPointer!Range && isIterable!(PointerTarget!Range) && !isNarrowString!Range && !isInfinite!Range)
/Library/D/dmd/src/phobos/std/array.d(232,31):        std.array.array(String)(scope String str) if (isNarrowString!String)
../../.dub/packages/fluent-asserts-0.8.5/fluent-asserts/core/fluentasserts/core/array.d(205,34): Error: template instance fluentasserts.core.array.toValueList!(immutable(string), void[]) error instantiating
source/valley/robots.d(344,34):        instantiated from here: containOnly!(void[])

bad name for `approximately` using durations

the value used for the approximately it can be some else than a number

(end - begin) should be equal `500 ms±50 ms`. `1 μs and 1 hnsec` is less than or equal to `450 ms`.

 Expected:a᛫number᛫inside᛫(450᛫ms,᛫550᛫ms)᛫interval

Objects should be comparable

actual.should.equal(expected) does not compile for objects:

Error: no property 'equal' for type 'ShouldObject!(Object)'

Crashing on Windows dmd when compiling with -m64

Given this file:

import fluent.asserts;

void main()
{}

unittest
{
    'a'.should.equal('b');
}

With this dub.json:

{
	"name": "asd",
	"dependencies": { "fluent-asserts": "~>0.8.4" }
}

And this command:

dub test --arch=x86_64 --compiler=dmd

Fluent-asserts simply crashes. The program works as expected if compiled with dub test --arch=x86 --compiler=dmd:

fluentasserts.core.base.TestException@source\app.d(8): 'a' should equal `b`.
                                                                            
 Expected:b                                                                 
   Actual:a                                                                 
                                                                            
--------------------                                                        
source\app.d:8                                                              
--------------------                                                        
     6: unittest                                                            
     7: {                                                                   
>    8:     'a'.should.equal('b');                                          
     9: }                                                                   
                                                                            
--------------------

Should fails when trying to compare std.container.array Ranges.

Morning,
It looks like Arrays (std.container.array) data types will cause test to not compile because the destructor is marked with @System. The error message looks similar to this:

@safe function ...should cannot call @system destructor std.container.array.Range(Array!string).RangeT.~this

Not sure what the correct solution is since there was an effort to make the code safe, but this is a valid range construct, so technically it should be supported. I personally have found the ability to compare ranges very useful since it provides diffs and therefore I personally would prefer it support all ranges.

Dependencies Fail to Build with Fluent Asserts 0.12.3 & DMD v2.083.1

For reference, this is on an Ubuntu 18.04 LTS system.

Building a project using Fluent Asserts 0.12.3 and DMD v2.083.1 results in a build failure that seems to originate from one of Fluent Assert's dependencies, Vibe 0.8.4.

The errors are shown below:

$ dub test --force
...
/home/vnayar/projects/s2geometry-d/../../.dub/packages/vibe-d-0.8.4/vibe-d/tls/vibe/stream/openssl.d:487: undefined reference to `SSLv23_server_method'
../../.dub/packages/vibe-d-0.8.4/vibe-d/tls/.dub/build/openssl-unittest-linux.posix-x86_64-dmd_2083-D7CD14B8E87984FDB1E0559879CA5174/libvibe-d_tls.a(openssl_f9_569.o): In function `_D4vibe6stream7openssl14OpenSSLContext11setDHParamsMFNeAyaZv':
/home/vnayar/projects/s2geometry-d/../../.dub/packages/vibe-d-0.8.4/vibe-d/tls/vibe/stream/openssl.d:725: undefined reference to `get_rfc3526_prime_2048'
../../.dub/packages/vibe-d-0.8.4/vibe-d/tls/.dub/build/openssl-unittest-linux.posix-x86_64-dmd_2083-D7CD14B8E87984FDB1E0559879CA5174/libvibe-d_tls.a(safestack_600_449.o): In function `_D6deimos7openssl9safestack__T10SKM_sk_numTSQBqQBm6x509v315GENERAL_NAME_stZ__TQBwZQCaFNbPSQDkQDgQDb__T8STACK_OFTQCrZQoZi':
/home/vnayar/projects/s2geometry-d/../../.dub/packages/openssl-1.1.6_1.0.1g/openssl/deimos/openssl/safestack.d:140: undefined reference to `sk_num'
../../.dub/packages/vibe-d-0.8.4/vibe-d/tls/.dub/build/openssl-unittest-linux.posix-x86_64-dmd_2083-D7CD14B8E87984FDB1E0559879CA5174/libvibe-d_tls.a(safestack_602_516.o): In function `_D6deimos7openssl9safestack__T12SKM_sk_valueTSQBsQBo6x509v315GENERAL_NAME_stZ__TQByZQCcFNbPSQDmQDiQDd__T8STACK_OFTQCrZQoiZPQDa':
/home/vnayar/projects/s2geometry-d/../../.dub/packages/openssl-1.1.6_1.0.1g/openssl/deimos/openssl/safestack.d:142: undefined reference to `sk_value'
collect2: error: ld returned 1 exit status

Better way to check exception messages

Currently this:

({
  throw new Exception("check me");
}).should.throwException!Exception.msg.should.contain("you");

Results in this:

... }).should.throwException!Exception.msg should contain `you` ...

I would like to see a better way to check exception messages, like this:

({
  throw new Exception("check me");
}).should.throwException!Exception.message.should.contain("you");

Which will give nice output:

... Message of Exception should contain `you`...

@safe(ty)

is it possible to make this library work along @safe unittests? currently the biggest drawback with using this is having to escentially disable @safety by marking the unittests @trusted

fluent-asserts version 0.10.0 fails at compilation

Brief description

Version 0.10.0 fails at compilation, whereas version 0.9.0 works well.

Error trace

dub upgrade && dub test -f -v
../../../../../home/khaled/.dub/packages/fluent-asserts-0.10.0/fluent-asserts/source/fluentasserts/vibe/json.d(24,3): Error: cannot infer argument types, expected 1 argument, not 2
../../../../../home/khaled/.dub/packages/fluent-asserts-0.10.0/fluent-asserts/source/fluentasserts/vibe/request.d(89,44): Error: @safe function 'fluentasserts.vibe.request.RequestRouter.post' cannot call @system constructor 'vibe.inet.url.URL.this'
../../../../../home/khaled/.dub/packages/fluent-asserts-0.10.0/fluent-asserts/source/fluentasserts/vibe/request.d(119,48): Error: @safe function 'fluentasserts.vibe.request.RequestRouter.customMethod!(cast(HTTPMethod)3).customMethod' cannot call @system function 'vibe.http.server.createTestHTTPServerRequest'
../../../../../home/khaled/.dub/packages/fluent-asserts-0.10.0/fluent-asserts/source/fluentasserts/vibe/request.d(120,3): Error: @safe function 'fluentasserts.vibe.request.RequestRouter.customMethod!(cast(HTTPMethod)3).customMethod' cannot call @system function 'vibe.http.common.HTTPRequest.host'
../../../../../home/khaled/.dub/packages/fluent-asserts-0.10.0/fluent-asserts/source/fluentasserts/vibe/request.d(89,40): Error: template instance fluentasserts.vibe.request.RequestRouter.customMethod!(cast(HTTPMethod)3) error instantiating
../../../../../home/khaled/.dub/packages/fluent-asserts-0.10.0/fluent-asserts/source/fluentasserts/vibe/request.d(94,45): Error: @safe function 'fluentasserts.vibe.request.RequestRouter.patch' cannot call @system constructor 'vibe.inet.url.URL.this'
../../../../../home/khaled/.dub/packages/fluent-asserts-0.10.0/fluent-asserts/source/fluentasserts/vibe/request.d(119,48): Error: @safe function 'fluentasserts.vibe.request.RequestRouter.customMethod!(cast(HTTPMethod)4).customMethod' cannot call @system function 'vibe.http.server.createTestHTTPServerRequest'
../../../../../home/khaled/.dub/packages/fluent-asserts-0.10.0/fluent-asserts/source/fluentasserts/vibe/request.d(120,3): Error: @safe function 'fluentasserts.vibe.request.RequestRouter.customMethod!(cast(HTTPMethod)4).customMethod' cannot call @system function 'vibe.http.common.HTTPRequest.host'
../../../../../home/khaled/.dub/packages/fluent-asserts-0.10.0/fluent-asserts/source/fluentasserts/vibe/request.d(94,41): Error: template instance fluentasserts.vibe.request.RequestRouter.customMethod!(cast(HTTPMethod)4) error instantiating
../../../../../home/khaled/.dub/packages/fluent-asserts-0.10.0/fluent-asserts/source/fluentasserts/vibe/request.d(99,43): Error: @safe function 'fluentasserts.vibe.request.RequestRouter.put' cannot call @system constructor 'vibe.inet.url.URL.this'
../../../../../home/khaled/.dub/packages/fluent-asserts-0.10.0/fluent-asserts/source/fluentasserts/vibe/request.d(119,48): Error: @safe function 'fluentasserts.vibe.request.RequestRouter.customMethod!(cast(HTTPMethod)2).customMethod' cannot call @system function 'vibe.http.server.createTestHTTPServerRequest'
../../../../../home/khaled/.dub/packages/fluent-asserts-0.10.0/fluent-asserts/source/fluentasserts/vibe/request.d(120,3): Error: @safe function 'fluentasserts.vibe.request.RequestRouter.customMethod!(cast(HTTPMethod)2).customMethod' cannot call @system function 'vibe.http.common.HTTPRequest.host'
../../../../../home/khaled/.dub/packages/fluent-asserts-0.10.0/fluent-asserts/source/fluentasserts/vibe/request.d(99,39): Error: template instance fluentasserts.vibe.request.RequestRouter.customMethod!(cast(HTTPMethod)2) error instantiating
../../../../../home/khaled/.dub/packages/fluent-asserts-0.10.0/fluent-asserts/source/fluentasserts/vibe/request.d(104,46): Error: @safe function 'fluentasserts.vibe.request.RequestRouter.delete_' cannot call @system constructor 'vibe.inet.url.URL.this'
../../../../../home/khaled/.dub/packages/fluent-asserts-0.10.0/fluent-asserts/source/fluentasserts/vibe/request.d(119,48): Error: @safe function 'fluentasserts.vibe.request.RequestRouter.customMethod!(cast(HTTPMethod)5).customMethod' cannot call @system function 'vibe.http.server.createTestHTTPServerRequest'
../../../../../home/khaled/.dub/packages/fluent-asserts-0.10.0/fluent-asserts/source/fluentasserts/vibe/request.d(120,3): Error: @safe function 'fluentasserts.vibe.request.RequestRouter.customMethod!(cast(HTTPMethod)5).customMethod' cannot call @system function 'vibe.http.common.HTTPRequest.host'
../../../../../home/khaled/.dub/packages/fluent-asserts-0.10.0/fluent-asserts/source/fluentasserts/vibe/request.d(104,42): Error: template instance fluentasserts.vibe.request.RequestRouter.customMethod!(cast(HTTPMethod)5) error instantiating
../../../../../home/khaled/.dub/packages/fluent-asserts-0.10.0/fluent-asserts/source/fluentasserts/vibe/request.d(109,43): Error: @safe function 'fluentasserts.vibe.request.RequestRouter.get' cannot call @system constructor 'vibe.inet.url.URL.this'
../../../../../home/khaled/.dub/packages/fluent-asserts-0.10.0/fluent-asserts/source/fluentasserts/vibe/request.d(119,48): Error: @safe function 'fluentasserts.vibe.request.RequestRouter.customMethod!(cast(HTTPMethod)0).customMethod' cannot call @system function 'vibe.http.server.createTestHTTPServerRequest'
../../../../../home/khaled/.dub/packages/fluent-asserts-0.10.0/fluent-asserts/source/fluentasserts/vibe/request.d(120,3): Error: @safe function 'fluentasserts.vibe.request.RequestRouter.customMethod!(cast(HTTPMethod)0).customMethod' cannot call @system function 'vibe.http.common.HTTPRequest.host'

Environment

"dependencies": {
    "vibe-d:core": "~>0.7.32",
    "vibe-d:redis": "~>0.7.32",
    "vibe-d:data": "~>0.7.32",
    "vibe-d:http": "~>0.7.32",
    "fluent-asserts": "==0.10.0"
}
dmd --version
DMD64 D Compiler v2.073.0-master-46940aa

improve usage of should.throwException

I can write

foo(0).should.equal(42);

But I cannot just write

foo(1).should.throwException!Exception;

Instead, I have to write it "ugly"

({ foo(1); }).should.throwException!Exception;

compare immutable with mutable values

fluent-asserts/core/fluentasserts/core/array.d(20,26): Error: cannot implicitly convert expression reference of type string[] to immutable(string)[]

checks with const actual no longer compile

unittest
{
    const actual = 42;
    actual.should.equal(42);
}

results in:

core/fluentasserts/core/base.d(449,5): Error: cannot modify const expression r.__expand_field_0
core/fluentasserts/core/base.d(513,39): Error: template instance fluentasserts.core.base.evaluate!(const(int)) error instantiating
instantiated from here: should!(const(int))

(for better reference, I created an issue from my earlier comment)

exception with message does not show the right sourcecode

 should throw a `CrateNotFoundException` with message equal ``. `The user does not exist.` is not equal to ``.
Diff:The user does not exist.


   Actual:The user does not exist.

../../.dub/packages/fluent-asserts-0.11.4/fluent-asserts/source/fluentasserts/core/base.d:417
   411:
   412:
   413:  auto withMessage(string expectedMessage) {
   414:    auto s = ShouldString(msg);
   415:    check = false;
   416:
>  417:    return s.forceMessage(messages ~ Message(false, " with message")).equal(expectedMessage);
   418:  }

cannot resolve type for should

cannot resolve type for should(delegate void delegate() @system() => delegate ()
{
getOther();
}
).throwException(T)(string file = __FILE__, size_t line = __LINE__)

Large git history

There seem to be a bunch of large-ish binary files in the git history of this project, bloating it up and thereby making initial clones much slower. It might be worth purging these from git history.

I was able to find the following binary files:

test/disabledDiffResult/disabled-diff-result-example
test/disabledDiffResult/disabled-message-result-example
test/disabledDiffResult/disabled-source-result-example
test/disabledMessageResult/disabled-message-result-example
test/disabledMessageResult/disabled-source-result-example
test/disabledSourceResult/disabled-source-result-example
trial-vibe

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.