Bug 17501 – Runnable unittest problem with AST rewrite

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dlang.org
Product
D
Version
D2
Platform
All
OS
All
Creation time
2017-06-14T09:45:58Z
Last change time
2017-08-14T23:55:48Z
Keywords
pull
Assigned to
No Owner
Creator
ZombineDev

Comments

Comment #0 by petar.p.kirov — 2017-06-14T09:45:58Z
I noticed that there are cases where the assert -> writeln rewrite does something wrong. Here's an example: http://dlang.org/phobos-prerelease/std_algorithm_iteration#.splitter.3 ---- import std.algorithm.comparison : equal; import std.range.primitives : front; writeln(a); // ' ' int[] a = [ 1, 2, 0, 0, 3, 0, 4, 5, 0 ]; int[][] w = [ [1, 2], [], [3], [4, 5], [] ]; writeln(a); // 0 a = [ 0 ]; writeln(a); // 0 a = [ 0, 1 ]; writeln(a); // 0 w = [ [0], [1], [2] ]; writeln(a.front); // 1 ---- And the actual unittest: ---- import std.algorithm.comparison : equal; import std.range.primitives : front; assert(equal(splitter!(a => a == ' ')("hello world"), [ "hello", "", "world" ])); int[] a = [ 1, 2, 0, 0, 3, 0, 4, 5, 0 ]; int[][] w = [ [1, 2], [], [3], [4, 5], [] ]; assert(equal(splitter!(a => a == 0)(a), w)); a = [ 0 ]; assert(equal(splitter!(a => a == 0)(a), [ (int[]).init, (int[]).init ])); a = [ 0, 1 ]; assert(equal(splitter!(a => a == 0)(a), [ [], [1] ])); w = [ [0], [1], [2] ]; assert(equal(splitter!(a => a.front == 1)(w), [ [[0]], [[2]] ])); ----
Comment #1 by greensunny12 — 2017-06-15T01:00:09Z
Thanks a lot for reporting! Pull: https://github.com/dlang/dlang.org/pull/1693
Comment #2 by github-bugzilla — 2017-06-15T03:15:24Z
Commits pushed to master at https://github.com/dlang/dlang.org https://github.com/dlang/dlang.org/commit/eae2ed4075709164d7d2de1682970f9b1c1a2d9a Fix Issue 17501 - Runnable unittest problem with AST rewrite https://github.com/dlang/dlang.org/commit/5bebaa7421e3cdb543c3d1f90c6856902a3fc561 Merge pull request #1693 from wilzbach/enable-tests Fix Issue 17501 - Runnable unittest problem with AST rewrite merged-on-behalf-of: Vladimir Panteleev <[email protected]>
Comment #3 by github-bugzilla — 2017-06-17T11:35:08Z
Commits pushed to stable at https://github.com/dlang/dlang.org https://github.com/dlang/dlang.org/commit/eae2ed4075709164d7d2de1682970f9b1c1a2d9a Fix Issue 17501 - Runnable unittest problem with AST rewrite https://github.com/dlang/dlang.org/commit/5bebaa7421e3cdb543c3d1f90c6856902a3fc561 Merge pull request #1693 from wilzbach/enable-tests
Comment #4 by github-bugzilla — 2017-08-14T23:55:48Z
Commits pushed to newCTFE at https://github.com/dlang/dlang.org https://github.com/dlang/dlang.org/commit/eae2ed4075709164d7d2de1682970f9b1c1a2d9a Fix Issue 17501 - Runnable unittest problem with AST rewrite https://github.com/dlang/dlang.org/commit/5bebaa7421e3cdb543c3d1f90c6856902a3fc561 Merge pull request #1693 from wilzbach/enable-tests