private void ParseAndEnsureEquality(string spec, Argument argument)
        {
            try
            {
                var parsedLiteral = ParseObjectLiteral(spec);

                if (parsedLiteral == UndefinedValue.Instance)
                {
                    Assert.Equal(argument, Cmd.Undefined());
                }
                else
                {
                    var parsedArgument = CommandLineArgumentsConverter.ObjectLiteralToArgument(
                        new Names(FrontEndContext.SymbolTable),
                        parsedLiteral as ObjectLiteral);
                    Assert.Equal(argument, parsedArgument);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Conversion failed for : " + spec.Split(new[] { Environment.NewLine }, StringSplitOptions.None).LastOrDefault());
                Console.WriteLine("    Exception : " + e.GetLogEventMessage());
                throw;
            }
        }
        public void TestConversionFailures(string literal)
        {
            try
            {
                // Explicit try-catch was used to print error message for debugging purposes.
                var parsedLiteral       = ParseObjectLiteral(literal);
                var parsedObjectLiteral = parsedLiteral as ObjectLiteral;

                if (parsedObjectLiteral != null)
                {
                    CommandLineArgumentsConverter.ObjectLiteralToArgument(new Names(FrontEndContext.SymbolTable), parsedObjectLiteral);
                }

                XAssert.Fail("DScript snippet '{0}' didn't fail as expected", literal);
            }
            catch (ConvertException e)
            {
                Console.WriteLine("Expected conversion exception happens. Message: " + e.Message);
            }
        }
        public void TestArgumentListProcessing()
        {
            // Arrange
            string Literal = String.Format(@"export const x: Argument[] = [
  Cmd.flag(""/nologo"", true),
  Cmd.option(""/timeout"", 42),
  Cmd.option(""/out"", Artifact.output(p`{0}foo.txt`)),
  Cmd.argument(p`{0}boo.txt`),
  Cmd.option(""/path"", p`{0}doo.txt`),
  Cmd.argument(PathAtom.create(""anAtom1"")),
  Cmd.option(""/atom"", PathAtom.create(""anAtom2"")),
  Cmd.option(""/rel"", RelativePath.create(""a/b/c"")),
  Cmd.argument(r`a/b/c`),
  Cmd.argument(r`a a/b b/c c`)
];", m_testAbsolutePath);

            // Act
            var parsedLiteral   = ParseArrayLiteral(WrapWithCmdApi(Literal));
            var parsedArguments = CommandLineArgumentsConverter.ArrayLiteralToListOfArguments(new Names(FrontEndContext.SymbolTable), parsedLiteral).ToArray();

            // Assert
            Assert.Equal(
                new[]
            {
                Cmd.Flag("/nologo"),
                Cmd.Option("/timeout", 42),
                Cmd.Option("/out", Artifacts.Output(CreateAbsolutePath(FrontEndContext, String.Format("{0}foo.txt", m_testAbsolutePath)))),
                Cmd.Argument(CreateAbsolutePath(FrontEndContext, String.Format("{0}boo.txt", m_testAbsolutePath))),
                Cmd.Option("/path", CreateAbsolutePath(FrontEndContext, String.Format("{0}doo.txt", m_testAbsolutePath))),
                Cmd.Argument(CreatePathAtom(FrontEndContext, "anAtom1")),
                Cmd.Option("/atom", CreatePathAtom(FrontEndContext, "anAtom2")),
                Cmd.Option("/rel", CreateRelativePath("a" + Path.DirectorySeparatorChar + "b" + Path.DirectorySeparatorChar + "c")),
                Cmd.Argument(CreateRelativePath("a" + Path.DirectorySeparatorChar + "b" + Path.DirectorySeparatorChar + "c")),
                Cmd.Argument(CreateRelativePath("a a" + Path.DirectorySeparatorChar + "b b" + Path.DirectorySeparatorChar + "c c"))
            },
                parsedArguments);
        }