diff options
author | michelou <michelou@epfl.ch> | 2007-03-20 17:59:27 +0000 |
---|---|---|
committer | michelou <michelou@epfl.ch> | 2007-03-20 17:59:27 +0000 |
commit | 9715d09e8069e5a7ea62ef06d9cefe342b5f1c8b (patch) | |
tree | 831fea75fb219fca7341efb41695109c6216e1b8 | |
parent | 3c1e6d6ce35246894bf96db35749956d59ff6885 (diff) | |
download | scala-9715d09e8069e5a7ea62ef06d9cefe342b5f1c8b.tar.gz scala-9715d09e8069e5a7ea62ef06d9cefe342b5f1c8b.tar.bz2 scala-9715d09e8069e5a7ea62ef06d9cefe342b5f1c8b.zip |
added Array.deepEquals, improved external links...
added Array.deepEquals, improved external links to sources in API doc
-rw-r--r-- | build.xml | 2 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/doc/DocGenerator.scala | 13 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/doc/script.js | 174 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/doc/source.png | bin | 431 -> 0 bytes | |||
-rw-r--r-- | src/library/scala/Array.scala | 20 | ||||
-rw-r--r-- | src/library/scala/runtime/BoxedArray.scala | 42 | ||||
-rw-r--r-- | test/files/run/deepToString.scala | 41 | ||||
-rw-r--r-- | test/files/run/deeps.check (renamed from test/files/run/deepToString.check) | 26 | ||||
-rw-r--r-- | test/files/run/deeps.scala | 84 |
9 files changed, 345 insertions, 57 deletions
@@ -248,7 +248,6 @@ BUILD SUPPORT MACROS <include name="**/*.xml"/> <include name="**/*.js"/> <include name="**/*.css"/> - <include name="**/*.png"/> </fileset> </copy> <copy todir="@{build.dir}/lib/compiler"> @@ -257,7 +256,6 @@ BUILD SUPPORT MACROS <include name="**/*.xml"/> <include name="**/*.js"/> <include name="**/*.css"/> - <include name="**/*.png"/> </fileset> </copy> </sequential> diff --git a/src/compiler/scala/tools/nsc/doc/DocGenerator.scala b/src/compiler/scala/tools/nsc/doc/DocGenerator.scala index 2140f9ee76..41e83f8383 100644 --- a/src/compiler/scala/tools/nsc/doc/DocGenerator.scala +++ b/src/compiler/scala/tools/nsc/doc/DocGenerator.scala @@ -689,16 +689,19 @@ abstract class DocGenerator extends Models { private def header0: NodeSeq = { val sym = clazz.tree.symbol - val name = sym.fullNameString.replace("$object", "") + val dir = + if (sym.toplevelClass.isPackageClass) sym.toplevelClass + else sym.toplevelClass.owner + val name = dir.fullNameString('/') + "/" + sym.sourceFile.name.replace(".scala", "") <span> <hr/> in {aref(urlFor(sym.owner), "_self", sym.owner.fullNameString('.'))} <div class="entity"> {Text(codeFor(kind))} <span class="entity">{Text(sym.nameString)}</span> - <a class={name.replace('.', '/')} href=""> - <img style="border:none;" src={relative +"/source.png"} alt="source" title={name}/> - </a> + </div> + <div style="font-size:smaller; color:gray;"> + [source: <a class={name} href=""><code>{name + ".scala"}</code></a>] </div> <hr/> </span>; @@ -1172,7 +1175,7 @@ abstract class DocGenerator extends Models { def descr = boxedValDescr(sym) } val rsrcdir = "scala/tools/nsc/doc/".replace('/', File.separatorChar) - for (val base <- List("style.css", "script.js", "source.png")) { + for (val base <- List("style.css", "script.js")) { try { val in = loader.getResourceAsStream(rsrcdir + base) val out = new FileOutputStream(new File(outdir + File.separator + base)) diff --git a/src/compiler/scala/tools/nsc/doc/script.js b/src/compiler/scala/tools/nsc/doc/script.js index 95db6afb98..e2c8f39cd4 100644 --- a/src/compiler/scala/tools/nsc/doc/script.js +++ b/src/compiler/scala/tools/nsc/doc/script.js @@ -361,6 +361,7 @@ function init() { src['scala/Responder'] = lib_svn_root; src['scala/Seq'] = lib_svn_root; src['scala/SeqProxy'] = lib_svn_root; + src['scala/SerialVersionUID'] = lib_svn_root; src['scala/Some'] = lib_svn_root; src['scala/StaticAnnotation'] = lib_svn_root; src['scala/Stream'] = lib_svn_root; @@ -391,8 +392,32 @@ function init() { src['scala/collection/SortedMap'] = lib_svn_root; src['scala/collection/SortedSet'] = lib_svn_root; src['scala/collection/immutable/BitSet'] = lib_svn_root; + src['scala/collection/immutable/EmptyMap'] = lib_svn_root; + src['scala/collection/immutable/EmptySet'] = lib_svn_root; src['scala/collection/immutable/HashMap'] = lib_svn_root; src['scala/collection/immutable/HashSet'] = lib_svn_root; + src['scala/collection/immutable/ImmutableIterator'] = lib_svn_root; + src['scala/collection/immutable/ListMap'] = lib_svn_root; + src['scala/collection/immutable/ListSet'] = lib_svn_root; + src['scala/collection/immutable/Map'] = lib_svn_root; + src['scala/collection/immutable/Map1'] = lib_svn_root; + src['scala/collection/immutable/Map2'] = lib_svn_root; + src['scala/collection/immutable/Map3'] = lib_svn_root; + src['scala/collection/immutable/Map4'] = lib_svn_root; + src['scala/collection/immutable/Queue'] = lib_svn_root; + src['scala/collection/immutable/RedBlack'] = lib_svn_root; + src['scala/collection/immutable/Set'] = lib_svn_root; + src['scala/collection/immutable/Set1'] = lib_svn_root; + src['scala/collection/immutable/Set2'] = lib_svn_root; + src['scala/collection/immutable/Set3'] = lib_svn_root; + src['scala/collection/immutable/Set4'] = lib_svn_root; + src['scala/collection/immutable/SortedMap'] = lib_svn_root; + src['scala/collection/immutable/SortedSet'] = lib_svn_root; + src['scala/collection/immutable/Stack'] = lib_svn_root; + src['scala/collection/immutable/Tree'] = lib_svn_root; + src['scala/collection/immutable/TreeMap'] = lib_svn_root; + src['scala/collection/immutable/TreeSet'] = lib_svn_root; + src['scala/collection/immutable/UnbalancedTreeMap'] = lib_svn_root; src['scala/collection/jcl/ArrayList'] = lib_svn_root; src['scala/collection/jcl/Buffer'] = lib_svn_root; src['scala/collection/jcl/BufferIterator'] = lib_svn_root; @@ -403,6 +428,26 @@ function init() { src['scala/collection/jcl/HashSet'] = lib_svn_root; src['scala/collection/jcl/IdentityHashMap'] = lib_svn_root; src['scala/collection/jcl/IterableWrapper'] = lib_svn_root; + src['scala/collection/jcl/LinkedHashMap'] = lib_svn_root; + src['scala/collection/jcl/LinkedHashSet'] = lib_svn_root; + src['scala/collection/jcl/LinkedList'] = lib_svn_root; + src['scala/collection/jcl/Map'] = lib_svn_root; + src['scala/collection/jcl/MapWrapper'] = lib_svn_root; + src['scala/collection/jcl/MutableIterable'] = lib_svn_root; + src['scala/collection/jcl/MutableIterator'] = lib_svn_root; + src['scala/collection/jcl/MutableSeq'] = lib_svn_root; + src['scala/collection/jcl/Ranged'] = lib_svn_root; + src['scala/collection/jcl/SeqIterator'] = lib_svn_root; + src['scala/collection/jcl/Set'] = lib_svn_root; + src['scala/collection/jcl/SetWrapper'] = lib_svn_root; + src['scala/collection/jcl/Sorted'] = lib_svn_root; + src['scala/collection/jcl/SortedMap'] = lib_svn_root; + src['scala/collection/jcl/SortedMapWrapper'] = lib_svn_root; + src['scala/collection/jcl/SortedSet'] = lib_svn_root; + src['scala/collection/jcl/SortedSetWrapper'] = lib_svn_root; + src['scala/collection/jcl/TreeMap'] = lib_svn_root; + src['scala/collection/jcl/TreeSet'] = lib_svn_root; + src['scala/collection/jcl/WeakHashMap'] = lib_svn_root; src['scala/collection/mutable/ArrayBuffer'] = lib_svn_root; src['scala/collection/mutable/BitSet'] = lib_svn_root; src['scala/collection/mutable/Buffer'] = lib_svn_root; @@ -410,6 +455,7 @@ function init() { src['scala/collection/mutable/DefaultEntry'] = lib_svn_root; src['scala/collection/mutable/HashMap'] = lib_svn_root; src['scala/collection/mutable/HashSet'] = lib_svn_root; + src['scala/collection/mutable/JavaMapAdaptor'] = lib_svn_root; src['scala/collection/mutable/Location'] = lib_svn_root; src['scala/collection/mutable/Map'] = lib_svn_root; src['scala/collection/mutable/MapProxy'] = lib_svn_root; @@ -438,7 +484,22 @@ function init() { src['scala/collection/mutable/SynchronizedSet'] = lib_svn_root; src['scala/collection/mutable/SynchronizedStack'] = lib_svn_root; src['scala/collection/mutable/Undoable'] = lib_svn_root; + src['scala/compat/StringBuilder'] = lib_svn_root; + src['scala/compat/Math'] = lib_svn_root; + src['scala/compat/Platform'] = lib_svn_root; src['scala/concurrent/Actor'] = lib_svn_root; + src['scala/concurrent/Channel'] = lib_svn_root; + src['scala/concurrent/Lock'] = lib_svn_root; + src['scala/concurrent/MailBox'] = lib_svn_root; + src['scala/concurrent/NameServer'] = lib_svn_root; + src['scala/concurrent/Pid'] = lib_svn_root; + src['scala/concurrent/Process'] = lib_svn_root; + src['scala/concurrent/SyncChannel'] = lib_svn_root; + src['scala/concurrent/SyncVar'] = lib_svn_root; + src['scala/concurrent/TIMEOUT'] = lib_svn_root; // object + src['scala/concurrent/jolib'] = lib_svn_root; // object + src['scala/concurrent/ops'] = lib_svn_root; // object + src['scala/concurrent/pilib'] = lib_svn_root; // object src['scala/io/BytePickle'] = lib_svn_root; src['scala/io/Position'] = lib_svn_root; @@ -453,11 +514,54 @@ function init() { src['scala/reflect/Type'] = lib_svn_root; src['scala/reflect/TypedCode'] = lib_svn_root; + src['scala/runtime/BoxedAnyArray'] = lib_svn_root; + src['scala/runtime/BoxedArray'] = lib_svn_root; + src['scala/runtime/BoxedBooleanArray'] = lib_svn_root; + src['scala/runtime/BoxedByteArray'] = lib_svn_root; + src['scala/runtime/BoxedCharArray'] = lib_svn_root; + src['scala/runtime/BoxedDoubleArray'] = lib_svn_root; + src['scala/runtime/BoxedFloatArray'] = lib_svn_root; + src['scala/runtime/BoxedIntArray'] = lib_svn_root; + src['scala/runtime/BoxedLongArray'] = lib_svn_root; + src['scala/runtime/BoxedObjectArray'] = lib_svn_root; + src['scala/runtime/BoxedShortArray'] = lib_svn_root; + src['scala/runtime/NonLocalReturnException'] = lib_svn_root; + src['scala/runtime/Nothing$'] = lib_svn_root; + src['scala/runtime/Null$'] = lib_svn_root; + src['scala/runtime/RichBoolean'] = lib_svn_root; + src['scala/runtime/RichByte'] = lib_svn_root; + src['scala/runtime/RichChar'] = lib_svn_root; + src['scala/runtime/RichDouble'] = lib_svn_root; + src['scala/runtime/RichException'] = lib_svn_root; + src['scala/runtime/RichFloat'] = lib_svn_root; + src['scala/runtime/RichInt'] = lib_svn_root; + src['scala/runtime/RichLong'] = lib_svn_root; + src['scala/runtime/RichShort'] = lib_svn_root; + src['scala/runtime/RichString'] = lib_svn_root; + src['scala/runtime/ScalaRunTime'] = lib_svn_root; + src['scala/runtime/StringAdd'] = lib_svn_root; + + src['scala/testing/Benchmark'] = lib_svn_root; + src['scala/testing/SUnit'] = lib_svn_root; + src['scala/testing/UnitTest'] = lib_svn_root; // object + src['scala/text/Document'] = lib_svn_root; src['scala/util/Fluid'] = lib_svn_root; - src['scala/util/RichSorting'] = lib_svn_root; src['scala/util/Sorting'] = lib_svn_root; + src['scala/util/automata/BaseBerrySethi'] = lib_svn_root; + src['scala/util/automata/DetWordAutom'] = lib_svn_root; + src['scala/util/automata/Inclusion'] = lib_svn_root; + src['scala/util/automata/NondetWordAutomata'] = lib_svn_root; + src['scala/util/automata/SubsetConstruction'] = lib_svn_root; + src['scala/util/automata/WordBerrySethi'] = lib_svn_root; + src['scala/util/grammar/HedgeRHS'] = lib_svn_root; + src['scala/util/grammar/TreeRHS'] = lib_svn_root; + src['scala/util/logging/ConsoleLogger'] = lib_svn_root; + src['scala/util/logging/Logged'] = lib_svn_root; + src['scala/util/parsing/CharInputStreamIterator'] = lib_svn_root; + src['scala/util/parsing/Parsers'] = lib_svn_root; + src['scala/util/parsing/SimpleTokenizer'] = lib_svn_root; src['scala/util/regexp/Base'] = lib_svn_root; src['scala/util/regexp/PointedHedgeExp'] = lib_svn_root; src['scala/util/regexp/SyntaxError'] = lib_svn_root; @@ -470,18 +574,54 @@ function init() { src['scala/xml/Entityef'] = lib_svn_root; src['scala/xml/Group'] = lib_svn_root; src['scala/xml/HasKeyValue'] = lib_svn_root; + src['scala/xml/MalformedAttributeException'] = lib_svn_root; + src['scala/xml/MetaData'] = lib_svn_root; + src['scala/xml/NamespaceBinding'] = lib_svn_root; src['scala/xml/Node'] = lib_svn_root; src['scala/xml/NodeBuffer'] = lib_svn_root; src['scala/xml/NodeSeq'] = lib_svn_root; src['scala/xml/NodeTraverser'] = lib_svn_root; - src['scala/xml/Null'] = lib_svn_root; + src['scala/xml/Null'] = lib_svn_root; // object src['scala/xml/PrettyPrinter'] = lib_svn_root; src['scala/xml/SpecialNode'] = lib_svn_root; src['scala/xml/Text'] = lib_svn_root; src['scala/xml/TextBuffer'] = lib_svn_root; + src['scala/xml/TopScope'] = lib_svn_root; // object src['scala/xml/TypeSymbol'] = lib_svn_root; src['scala/xml/Unparsed'] = lib_svn_root; src['scala/xml/UnprefixedAttribute'] = lib_svn_root; + src['scala/xml/Utility'] = lib_svn_root; + src['scala/xml/XML'] = lib_svn_root; + src['scala/xml/dtd/ContentModel'] = lib_svn_root; + src['scala/xml/dtd/ContentModelParser'] = lib_svn_root; + src['scala/xml/dtd/DTD'] = lib_svn_root; + src['scala/xml/dtd/Decl'] = lib_svn_root; + src['scala/xml/dtd/DocType'] = lib_svn_root; + src['scala/xml/dtd/DtdTypeSymbol'] = lib_svn_root; + src['scala/xml/dtd/ElementValidator'] = lib_svn_root; + src['scala/xml/dtd/ExternalID'] = lib_svn_root; + src['scala/xml/dtd/Scanner'] = lib_svn_root; + src['scala/xml/dtd/Tokens'] = lib_svn_root; + src['scala/xml/factory/Binder'] = lib_svn_root; + src['scala/xml/factory/LoggedNodeFactory'] = lib_svn_root; + src['scala/xml/factory/NodeFactory'] = lib_svn_root; + src['scala/xml/parsing/ConstructingHandler'] = lib_svn_root; + src['scala/xml/parsing/ConstructingParser'] = lib_svn_root; + src['scala/xml/parsing/DefaultMarkupHandler'] = lib_svn_root; + src['scala/xml/parsing/ExternalSources'] = lib_svn_root; + src['scala/xml/parsing/FactoryAdapter'] = lib_svn_root; + src['scala/xml/parsing/FatalError'] = lib_svn_root; + src['scala/xml/parsing/MarkupHandler'] = lib_svn_root; + src['scala/xml/parsing/MarkupParser'] = lib_svn_root; + src['scala/xml/parsing/NoBindingFactoryAdapter'] = lib_svn_root; + src['scala/xml/parsing/TokenTests'] = lib_svn_root; + src['scala/xml/parsing/ValidatingMarkupHandler'] = lib_svn_root; + src['scala/xml/path/Expression'] = lib_svn_root; + src['scala/xml/pull/XMLEvent'] = lib_svn_root; + src['scala/xml/pull/XMLEventReader'] = lib_svn_root; + src['scala/xml/transform/BasicTransformer'] = lib_svn_root; + src['scala/xml/transform/RewriteRule'] = lib_svn_root; + src['scala/xml/transform/RuleTransformer'] = lib_svn_root; // scala-actors-src.jar src['scala/actors/Actor'] = actors_svn_root; @@ -555,8 +695,38 @@ function init() { src['scala/dbc/statement/Table'] = dbc_svn_root; src['scala/dbc/statement/Transaction'] = dbc_svn_root; src['scala/dbc/statement/Update'] = dbc_svn_root; + src['scala/dbc/statement/expression/Aggregate'] = dbc_svn_root; + src['scala/dbc/statement/expression/BinaryOperator'] = dbc_svn_root; + src['scala/dbc/statement/expression/Constant'] = dbc_svn_root; + src['scala/dbc/statement/expression/Default'] = dbc_svn_root; + src['scala/dbc/statement/expression/Field'] = dbc_svn_root; + src['scala/dbc/statement/expression/FunctionCall'] = dbc_svn_root; + src['scala/dbc/statement/expression/Select'] = dbc_svn_root; + src['scala/dbc/statement/expression/SetFunction'] = dbc_svn_root; + src['scala/dbc/statement/expression/TypeCast'] = dbc_svn_root; + src['scala/dbc/statement/expression/UnaryOperator'] = dbc_svn_root; + src['scala/dbc/syntax/DataTypeUtil'] = dbc_svn_root; + src['scala/dbc/syntax/Database'] = dbc_svn_root; + src['scala/dbc/syntax/Statement'] = dbc_svn_root; + src['scala/dbc/syntax/StatementExpression'] = dbc_svn_root; + src['scala/dbc/value/ApproximateNumeric'] = dbc_svn_root; + src['scala/dbc/value/Boolean'] = dbc_svn_root; + src['scala/dbc/value/Character'] = dbc_svn_root; + src['scala/dbc/value/CharacterLargeObject'] = dbc_svn_root; + src['scala/dbc/value/CharacterVarying'] = dbc_svn_root; + src['scala/dbc/value/Conversion'] = dbc_svn_root; + src['scala/dbc/value/ExactNumeric'] = dbc_svn_root; + src['scala/dbc/value/Factory'] = dbc_svn_root; + src['scala/dbc/value/Unknown'] = dbc_svn_root; // scala-compiler-src.jar + src['scala/tools/nsc/CompilationUnits'] = comp_svn_root; + src['scala/tools/nsc/CompileClient'] = comp_svn_root; + src['scala/tools/nsc/CompileServer'] = comp_svn_root; + src['scala/tools/nsc/CompileSocket'] = comp_svn_root; + src['scala/tools/nsc/CompilerCommand'] = comp_svn_root; + src['scala/tools/nsc/CompilerRun'] = comp_svn_root; + src['scala/tools/nsc/ConsoleWriter'] = comp_svn_root; src['scala/tools/nsc/Global'] = comp_svn_root; src['scala/tools/nsc/symtab/Definitions'] = comp_svn_root; diff --git a/src/compiler/scala/tools/nsc/doc/source.png b/src/compiler/scala/tools/nsc/doc/source.png Binary files differdeleted file mode 100644 index ecbca8cad7..0000000000 --- a/src/compiler/scala/tools/nsc/doc/source.png +++ /dev/null diff --git a/src/library/scala/Array.scala b/src/library/scala/Array.scala index be53af2ff0..21a65a284b 100644 --- a/src/library/scala/Array.scala +++ b/src/library/scala/Array.scala @@ -315,4 +315,24 @@ final class Array[A](_length: Int) extends Seq[A] { */ def deepMkString(sep: String): String = throw new Error() + /** <p> + * Returns <code>true</code> if the two specified arrays are + * <em>deeply equal</em> to one another. + * </p> + * <p> + * Two array references are considered deeply equal if both are null, + * or if they refer to arrays that contain the same number of elements + * and all corresponding pairs of elements in the two arrays are deeply + * equal. + * </p> + * <p> + * See also method <code>deepEquals</code> in the Java class + * <a href="http://java.sun.com/javase/6/docs/api/java/util/Arrays.html" + * target="_top">java.utils.Arrays</a> + * </p> + * + * @param that the second + * @return <code>true</code> iff both arrays are deeply equal. + */ + def deepEquals(that: Any): Boolean = throw new Error() } diff --git a/src/library/scala/runtime/BoxedArray.scala b/src/library/scala/runtime/BoxedArray.scala index cead9fb1a2..bc44e93a37 100644 --- a/src/library/scala/runtime/BoxedArray.scala +++ b/src/library/scala/runtime/BoxedArray.scala @@ -18,6 +18,9 @@ import compat.StringBuilder /** * <p>A class representing <code>Array[T]</code></p> + * + * @author Martin Odersky, Stephane Micheloud + * @version 1.0 */ abstract class BoxedArray extends Seq[Any] { /** The length of the array */ @@ -121,19 +124,13 @@ abstract class BoxedArray extends Seq[Any] { final def deepToString() = deepMkString(stringPrefix + "(", ",", ")") final def deepMkString(start: String, sep: String, end: String): String = { - val buf = new StringBuilder() - deepAddString(buf, start, sep, end).toString - } - - final def deepMkString(sep: String): String = this.deepMkString("", sep, "") - - private def deepAddString(buf: StringBuilder, start: String, sep: String, end: String): StringBuilder = { def _deepToString(x: Any) = x match { case a: AnyRef if ScalaRunTime.isArray(a) => ScalaRunTime.boxArray(a).deepMkString(start, sep, end) case _ => x.toString } + val buf = new StringBuilder() buf.append(start) val elems = elements if (elems.hasNext) buf.append(_deepToString(elems.next)) @@ -141,6 +138,37 @@ abstract class BoxedArray extends Seq[Any] { buf.append(sep); buf.append(_deepToString(elems.next)) } buf.append(end) + buf.toString + } + + final def deepMkString(sep: String): String = this.deepMkString("", sep, "") + + final def deepEquals(that: Any): Boolean = { + def _deepEquals(x1: Any, x2: Any) = (x1, x2) match { + case (a1: BoxedArray, a2: BoxedArray) => + _sameElements(a1, a2) + case (a1: AnyRef, a2: AnyRef) + if ScalaRunTime.isArray(a1) && ScalaRunTime.isArray(a2) => + _sameElements(ScalaRunTime.boxArray(a1), ScalaRunTime.boxArray(a2)) + case _ => + x1.equals(x2) + } + def _sameElements(a1: BoxedArray, a2: BoxedArray): Boolean = { + val it1 = a1.elements + val it2 = a2.elements + var res = true + while (res && it1.hasNext && it2.hasNext) + res = _deepEquals(it1.next, it2.next) + !it1.hasNext && !it2.hasNext && res + } + that match { + case a: BoxedArray => + _sameElements(this, a) + case a: AnyRef if ScalaRunTime.isArray(a) => + _sameElements(this, ScalaRunTime.boxArray(a)) + case _ => + false + } } override final def stringPrefix: String = "Array" diff --git a/test/files/run/deepToString.scala b/test/files/run/deepToString.scala deleted file mode 100644 index 1fb73fe5a5..0000000000 --- a/test/files/run/deepToString.scala +++ /dev/null @@ -1,41 +0,0 @@ -object Test extends Application { - - def sweep(s: String) = - s.replaceAll("D@[0-9a-fA-F]+", "D@0000000") - .replaceAll("Z@[0-9a-fA-F]+", "Z@0000000") - .replaceAll(";@[0-9a-fA-F]+", ";@0000000") - - def test[A](a: Array[A]) { - Console.println(sweep(a.toString)) - Console.println(a.deepToString) - Console.println(a.deepMkString("[", ";", "]")) - Console.println(a.deepMkString(";")) - Console.println - } - - val ba1 = Array(true, false) - val ba2 = Array(ba1, ba1) - val ba3 = Array(ba2, ba2) - test(ba1) - test(ba2) - test(ba3) - - val da1 = Array(1.0d, 0.0d) - val da2 = Array(da1, da1) - val da3 = Array(da2, da2) - test(da1) - test(da2) - test(da3) - - val sa1 = Array("a", "b") - val sa2 = Array(sa1, sa1) - val sa3 = Array(sa2, sa2) - test(sa1) - test(sa2) - test(sa3) - - Console.println(Array(Array(true, false), Array(false)).deepMkString("[", "; ", "]")) - Console.println(Array(Array('1', '2'), Array('3')).deepMkString("[", "; ", "]")) - Console.println(Array(Array(1, 2), Array(3)).deepMkString("[", "; ", "]")) - Console.println -} diff --git a/test/files/run/deepToString.check b/test/files/run/deeps.check index fcc0e04575..abcd5b52c3 100644 --- a/test/files/run/deepToString.check +++ b/test/files/run/deeps.check @@ -1,3 +1,29 @@ +false +false +true + +false +false +true + +x=Array(1) +y=Array(1) +false +false +true + +x=Array(Array(1),Array(1)) +y=Array(Array(1),Array(1)) +false +false +true + +x=Array(Array(Array(1),Array(1)),Array(Array(1),Array(1))) +y=Array(Array(Array(1),Array(1)),Array(Array(1),Array(1))) +false +false +true + Array(true,false) Array(true,false) [true;false] diff --git a/test/files/run/deeps.scala b/test/files/run/deeps.scala new file mode 100644 index 0000000000..46377b1523 --- /dev/null +++ b/test/files/run/deeps.scala @@ -0,0 +1,84 @@ +object Test extends Application { + + def testEquals1 { + Console.println(Array(1) == Array(1)) + Console.println(Array(1) equals Array(1)) + Console.println(Array(1) deepEquals Array(1)) + Console.println + } + + def testEquals2 { + Console.println(Array(Array(1), Array(2)) == Array(Array(1), Array(2))) + Console.println(Array(Array(1), Array(2)) equals Array(Array(1), Array(2))) + Console.println(Array(Array(1), Array(2)) deepEquals Array(Array(1), Array(2))) + Console.println + } + + def testEquals3 { + val a1 = Array(1) + val b1 = Array(1) + val a2 = Array(a1, b1) + val b2 = Array(a1, b1) + val a3 = Array(a2, b2) + val b3 = Array(a2, b2) + def test[T](x: Array[T], y: Array[T]) { + Console.println("x=" + x.deepToString) + Console.println("y=" + y.deepToString) + Console.println(x == y) + Console.println(x equals y) + Console.println(x deepEquals y) + Console.println + } + test(a1, b1) + test(a2, b2) + test(a3, b3) + } + + def testToString1 { + def sweep(s: String) = + s.replaceAll("D@[0-9a-fA-F]+", "D@0000000") + .replaceAll("Z@[0-9a-fA-F]+", "Z@0000000") + .replaceAll(";@[0-9a-fA-F]+", ";@0000000") + def test[T](a: Array[T]) { + Console.println(sweep(a.toString)) + Console.println(a.deepToString) + Console.println(a.deepMkString("[", ";", "]")) + Console.println(a.deepMkString(";")) + Console.println + } + + val ba1 = Array(true, false) + val ba2 = Array(ba1, ba1) + val ba3 = Array(ba2, ba2) + test(ba1) + test(ba2) + test(ba3) + + val da1 = Array(1.0d, 0.0d) + val da2 = Array(da1, da1) + val da3 = Array(da2, da2) + test(da1) + test(da2) + test(da3) + + val sa1 = Array("a", "b") + val sa2 = Array(sa1, sa1) + val sa3 = Array(sa2, sa2) + test(sa1) + test(sa2) + test(sa3) + } + + def testToString2 { + Console.println(Array(Array(true, false), Array(false)).deepMkString("[", "; ", "]")) + Console.println(Array(Array('1', '2'), Array('3')).deepMkString("[", "; ", "]")) + Console.println(Array(Array(1, 2), Array(3)).deepMkString("[", "; ", "]")) + Console.println + } + + testEquals1 + testEquals2 + testEquals3 + testToString1 + testToString2 +} |