Permalink
Browse files

Fix for regression bug# 8450.

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 3bd83aad16049fe037b1cded8e386fb9a509b313
Showing with 27 additions and 16 deletions.
  1. +27 −16 std/datetime.d
View
@@ -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() {}
@@ -31029,7 +31016,6 @@ version(testStdDateTime) @safe unittest
//static auto b2 = comparingBenchmark!(f1x, f2x, 1); // NG
}
version(testStdDateTime) unittest
{
void f1x() {}
@@ -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.
@@ -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
{
@@ -32082,7 +32082,7 @@ else
}
auto measureTime(alias func)()
if(!isSafe!func)
if(!isSafelyCallable!((){StopWatch sw; unaryFun!func(sw.peek());}))
{
struct Result
{
@@ -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.
//==============================================================================

0 comments on commit 3bd83aa

Please sign in to comment.