On Sat, 14 Aug 2010 14:58:05 +0200, simendsjo wrote:
> c:\temp\src\test.d
>
> c:\temp>rdmd src\test
> The system cannot find the path specified.
>
> c:\temp>rdmd src/test
> std.file.FileException: (...)\.rdmd\rdmd-src/test.d-(...): The system
> cannot find the path specified.
>
> Using rdmd 200
Is there a standard and/or acceptable way to make sure that pre-conditions,
post-conditions, or invariants _fail_ when running unit tests? That is, lets
say
I had a function like this
void func(int x)
in
{
assert(x < 8);
}
body
{
//...
}
and I wanted to test to make sure that func() cou
Is this a bug? Unit tests do not seem to work in libraries. I'm using dmd
1.062 for linux.
mylib.d :
module mylib;
void blah()
{
}
unittest
{
assert(false);
}
main.d :
module main;
import mylib;
void main()
{
blah();
}
The unit test does not get run when compiled as:
dmd -lib
I settled this just using an enum value passed as template argument:
---
enum DatePart
{
Year,
Month,
Day,
}
struct DatePartImpl(T : DatePart )
{
// Insert implementation here...
}
alias DatePartImpl!(DatePart.Year) Year;
alias DatePartImpl!(DatePart.Month) Month;
alias DatePar
On Sat, 14 Aug 2010 20:34:02 -0500, Jonathan M Davis
wrote:
Well, if you search the D list for typedef, you should find some posts
that
suggest templated structs combined with alias which get you typedefs. It
sounds
like something like that will probably end up in Phobos at some point,
t
On Sat, 14 Aug 2010 20:28:56 -0500, sybrandy wrote:
I can't recall if you can do this with structs, but if you use classes,
you should be able to define a "Date Part" class that has all of the
methods and data you want. Then, you just derive three sub-classes.
For example (and I hope the
On Saturday 14 August 2010 18:15:40 Yao G. wrote:
> On Sat, 14 Aug 2010 20:05:04 -0500, Jonathan M Davis
>
> wrote:
> > [snip]
> >
> > Are you looking to create a new type that while technically identical to
> > another type is not considered the same as that type by the type system?
> >
> > -
I can't recall if you can do this with structs, but if you use classes,
you should be able to define a "Date Part" class that has all of the
methods and data you want. Then, you just derive three sub-classes.
For example (and I hope the syntax is right):
class DatePart
{
this(int f)
{
On Sat, 14 Aug 2010 20:05:04 -0500, Jonathan M Davis
wrote:
[snip]
Are you looking to create a new type that while technically identical to
another type is not considered the same as that type by the type system?
- Jonathan M Davis
Yes, This is exactly what I want. I need, for example, th
Okay, I'm not familiar with what typedef is supposed to have done in D. I've
only ever used alias. But what is wrong with
On Saturday 14 August 2010 17:47:44 Yao G. wrote:
> // This should be typedef, but as it's going to be deprecated...
> alias Foo Year;
> alias Foo Month;
> alias Foo Day;
Is
Hello.
Is there an alternative to typedef? I need to define three structs that
have exactly the same methods and properties, yet represent different
stuff.
Example:
---
struct Foo
{
this( int f ) {
_foo = f;
}
int asNumber() {
return _foo;
}
private imm
I don't think that this syntax is supported at all.
You need to use __gshared with the instance instead:
__gshared foo f;
c:\temp\src\test.d
c:\temp>rdmd src\test
The system cannot find the path specified.
c:\temp>rdmd src/test
std.file.FileException: (...)\.rdmd\rdmd-src/test.d-(...): The system
cannot find the path specified.
Using rdmd 20090902, dmd 2.048 and 64 bit win7
__gshared struct foo {
int n;
}
foo f;
This f is not shared between threads, even though the
__gshared indicates it should be. Why is this not an error?
--
Simen
Steven Schveighoffer wrote:
1. a function may have the same name and usage, but have a completely
different meaning. Human languages are funny that way. This means,
your function could accept a type as a parameter and use it in a very
wrong way. Most of the time, this is a non issue, be
15 matches
Mail list logo