In reply to juhi_p:
It fails because your assertion statement is wrong. The randomize() function returns a 1 upon success, and a 0 upon failure, hence your assert() failure. Also, you should never use an assert statement with a task/function call because if you disable assertions to speed up simulation, these functions will never be called.
You want to check the return code from the randomize() call with an if statement, as was originally done:
if (!b.randomize()) begin
$fatal("Randomize() call failed!");
end
else begin
$display("Randomize() call was successful");
end