Skip to content

Commit

Permalink
Fix for regression bug# 8450.
Browse files Browse the repository at this point in the history
This requires the fix for bug# 8362 in order to compile and work.
  • Loading branch information
jmdavis committed Jul 27, 2012
1 parent c005f33 commit 3bd83aa
Showing 1 changed file with 27 additions and 16 deletions.
43 changes: 27 additions & 16 deletions std/datetime.d
Expand Up @@ -30998,27 +30998,14 @@ void main() {
}
--------------------
+/
@safe ComparingBenchmarkResult comparingBenchmark(alias baseFunc,
alias targetFunc,
int times = 0xfff)()
if(isSafe!baseFunc && isSafe!targetFunc)
{
auto t = benchmark!(baseFunc, targetFunc)(times);
return ComparingBenchmarkResult(t[0], t[1]);
}


/++ Ditto +/
ComparingBenchmarkResult comparingBenchmark(alias baseFunc,
alias targetFunc,
int times = 0xfff)()
if(!isSafe!baseFunc || !isSafe!targetFunc)
{
auto t = benchmark!(baseFunc, targetFunc)(times);
return ComparingBenchmarkResult(t[0], t[1]);
}


version(testStdDateTime) @safe unittest
{
void f1x() {}
Expand All @@ -31029,7 +31016,6 @@ version(testStdDateTime) @safe unittest
//static auto b2 = comparingBenchmark!(f1x, f2x, 1); // NG
}


version(testStdDateTime) unittest
{
void f1x() {}
Expand All @@ -31040,6 +31026,20 @@ version(testStdDateTime) unittest
auto b2 = comparingBenchmark!(f1x, f2x, 1)(); // OK
}

//Bug# 8450
version(testStdDateTime) unittest
{
@safe void safeFunc() {}
@trusted void trustFunc() {}
@system void sysFunc() {}
auto safeResult = comparingBenchmark!((){safeFunc();}, (){safeFunc();})();
auto trustResult = comparingBenchmark!((){trustFunc();}, (){trustFunc();})();
auto sysResult = comparingBenchmark!((){sysFunc();}, (){sysFunc();})();
auto mixedResult1 = comparingBenchmark!((){safeFunc();}, (){trustFunc();})();
auto mixedResult2 = comparingBenchmark!((){trustFunc();}, (){sysFunc();})();
auto mixedResult3 = comparingBenchmark!((){safeFunc();}, (){sysFunc();})();
}


//==============================================================================
// Section with public helper functions and templates.
Expand Down Expand Up @@ -32064,7 +32064,7 @@ writeln("benchmark end!");
else
{
@safe auto measureTime(alias func)()
if(isSafe!func)
if(isSafelyCallable!((){StopWatch sw; unaryFun!func(sw.peek());}))
{
struct Result
{
Expand All @@ -32082,7 +32082,7 @@ else
}

auto measureTime(alias func)()
if(!isSafe!func)
if(!isSafelyCallable!((){StopWatch sw; unaryFun!func(sw.peek());}))
{
struct Result
{
Expand Down Expand Up @@ -32136,6 +32136,17 @@ version(testStdDateTime) unittest
+/
}

//Bug# 8450
version(testStdDateTime) unittest
{
@safe void safeFunc() {}
@trusted void trustFunc() {}
@system void sysFunc() {}
auto safeResult = measureTime!((a){safeFunc();})();
auto trustResult = measureTime!((a){trustFunc();})();
auto sysResult = measureTime!((a){sysFunc();})();
}

//==============================================================================
// Private Section.
//==============================================================================
Expand Down

0 comments on commit 3bd83aa

Please sign in to comment.