<commit_before>using System;
using NUnit.Framework;
using System.Management.Automation;
using TestPSSnapIn;
using System.Runtime.InteropServices;

namespace ReferenceTests.Language
{
    public class ArrayTests : ReferenceTestBase
    {
        [TestCase("1,2,3")]
        [TestCase(",2")]
        [TestCase("@('foo',2,3)")]
        public void ArrayExpressionIsArrayType(string definition)
        {
            var cmd = String.Format("$a = {0}; $a.GetType().FullName", definition);
            var result = ReferenceHost.Execute(cmd);
            Assert.AreEqual(NewlineJoin(typeof(object[]).FullName), result);
        }

        [TestCase("1,2,3")]
        [TestCase("@(1,2,3)")]
        [TestCase("$a = @(1,2,3); $a")]
        [TestCase("$a = 1,2,3; $a")]
        public void ArrayIsEvaluatedWhenWrittenToPipeline(string cmd)
        {
            ExecuteAndCompareTypedResult(cmd, 1, 2, 3);
        }

        [Test]
        public void EmptyArrayWorks()
        {
            var cmd = "$a = @(); $a.Length";
            Assert.AreEqual(NewlineJoin("0"), ReferenceHost.Execute(cmd));
        }

        [Test]
        public void NestedOneDimensionalArrayEvaluates()
        {
            var results = ReferenceHost.RawExecute("@(@(@('foo')))");
            Assert.AreEqual(1, results.Count);
            Assert.AreEqual(PSObject.AsPSObject("foo"), results[0]);
        }

        [Test]
        public void NestedOneDimensionalArrayEvaluatesInArrayList()
        {
            var cmd = "$a = 1,2,@(4),,3; $a.Length; $a[2].GetType().FullName; $a[3].GetType().FullName";
            var objArrayName = typeof(object[]).FullName;
            Assert.AreEqual(NewlineJoin("4",objArrayName, objArrayName), ReferenceHost.Execute(cmd));
        }

        [Test]
        public void ElementsFromPipelineAreStoredAsArray()
        {
            var result = ReferenceHost.Execute(NewlineJoin(
                "$a = @('foo', 'bar', 'baz') | " + CmdletName(typeof(TestCmdletPhasesCommand)),
                "$a.GetType().FullName"
            ));
            Assert.AreEqual(NewlineJoin(typeof(object[]).FullName), result);
        }

        [Test]
        public void ArrayInParenthesisIsStillArray()
        {
            var result = ReferenceHost.Execute("(@(1,2)).GetType().FullName");
            Assert.AreEqual(NewlineJoin(typeof(object[]).FullName), result);
        }

        [Test] // issue #116
        public void SingleArrayElementIsStillArray()
        {
            var result = ReferenceHost.Execute("@(1).GetType().FullName; @(1).Count");
            Assert.AreEqual(NewlineJoin(typeof(object[]).FullName, "1"), result);
        }

        [Test]
        public void NestedTwoDimensionalArrayWorks()
        {
            var results = ReferenceHost.RawExecute("@(@(@('foo')), @(@('bar')))");
            Assert.AreEqual(2, results.Count);
            var expected = new[] { "foo", "bar" };
            for (int i = 0; i < 2; i++)
            {
                var psobjSubarray = results[i];
                Assert.IsInstanceOf<PSObject>(psobjSubarray);
                var subarray = ((PSObject)psobjSubarray).BaseObject as object[];
                Assert.NotNull(subarray);
                Assert.AreEqual(PSObject.AsPSObject(expected[i]), subarray[0]);

            }
        }
    }
}

<commit_msg>Changed tests to kill Pashs workaround<commit_after>using System;
using NUnit.Framework;
using System.Management.Automation;
using TestPSSnapIn;
using System.Runtime.InteropServices;

namespace ReferenceTests.Language
{
    public class ArrayTests : ReferenceTestBase
    {
        [TestCase("1,2,3")]
        [TestCase(",2")]
        [TestCase("@('foo',2,3)")]
        public void ArrayExpressionIsArrayType(string definition)
        {
            var cmd = String.Format("$a = {0}; $a.GetType().FullName", definition);
            var result = ReferenceHost.Execute(cmd);
            Assert.AreEqual(NewlineJoin(typeof(object[]).FullName), result);
        }

        [TestCase("1,2,3")]
        [TestCase("@(1,2,3)")]
        [TestCase("$a = @(1,2,3); $a")]
        [TestCase("$a = 1,2,3; $a")]
        public void ArrayIsEvaluatedWhenWrittenToPipeline(string cmd)
        {
            // last "; 0" makes sure it's in the middle of a script block
            ExecuteAndCompareTypedResult(cmd + "; 0", 1, 2, 3, 0);
        }

        [Test]
        public void EmptyArrayWorks()
        {
            var cmd = "$a = @(); $a.Length";
            Assert.AreEqual(NewlineJoin("0"), ReferenceHost.Execute(cmd));
        }

        [Test]
        public void NestedOneDimensionalArrayEvaluates()
        {
            var results = ReferenceHost.RawExecute("@(@(@('foo')))");
            Assert.AreEqual(1, results.Count);
            Assert.AreEqual(PSObject.AsPSObject("foo"), results[0]);
        }

        [Test]
        public void NestedOneDimensionalArrayEvaluatesInArrayList()
        {
            var cmd = "$a = 1,2,@(4),,3; $a.Length; $a[2].GetType().FullName; $a[3].GetType().FullName";
            var objArrayName = typeof(object[]).FullName;
            Assert.AreEqual(NewlineJoin("4",objArrayName, objArrayName), ReferenceHost.Execute(cmd));
        }

        [Test]
        public void ElementsFromPipelineAreStoredAsArray()
        {
            var result = ReferenceHost.Execute(NewlineJoin(
                "$a = @('foo', 'bar', 'baz') | " + CmdletName(typeof(TestCmdletPhasesCommand)),
                "$a.GetType().FullName"
            ));
            Assert.AreEqual(NewlineJoin(typeof(object[]).FullName), result);
        }

        [Test]
        public void ArrayInParenthesisIsStillArray()
        {
            var result = ReferenceHost.Execute("(@(1,2)).GetType().FullName");
            Assert.AreEqual(NewlineJoin(typeof(object[]).FullName), result);
        }

        [Test] // issue #116
        public void SingleArrayElementIsStillArray()
        {
            var result = ReferenceHost.Execute("@(1).GetType().FullName; @(1).Count");
            Assert.AreEqual(NewlineJoin(typeof(object[]).FullName, "1"), result);
        }

        [Test]
        public void NestedTwoDimensionalArrayWorks()
        {
            var results = ReferenceHost.RawExecute("@(@(@('foo')), @(@('bar')))");
            Assert.AreEqual(2, results.Count);
            var expected = new[] { "foo", "bar" };
            for (int i = 0; i < 2; i++)
            {
                var psobjSubarray = results[i];
                Assert.IsInstanceOf<PSObject>(psobjSubarray);
                var subarray = ((PSObject)psobjSubarray).BaseObject as object[];
                Assert.NotNull(subarray);
                Assert.AreEqual(PSObject.AsPSObject(expected[i]), subarray[0]);

            }
        }
    }
}


{'fraction_non_alphanumeric': 0.14960047351287364, 'fraction_numerical': 0.013465522343888724, 'mean_word_length': 2.221639656816015, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5146043', 'n_tokens_mistral': 2014, 'n_tokens_neox': 1949, 'n_words': 337}