text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using APL.SyntaxTreeGeneration;
using APL.Errors;

namespace APL.Runtime
{
    class APLMatrixVariable:APLVariable
    {
        private List<List<APLVariable>> _vals = new List<List<APLVariable>>();
        private int                     _cols = 0;

        /***
         * Common APLVariable Functions
         ***/

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="items">List of items in the array</param>
        /// <param name="columns">number of columns in the array (to calculate row amount)</param>
        public APLMatrixVariable(List<APLVariable> items, int columns)
        {
            if (items.Count % columns != 0)
                throw new APLRuntimeError("Invalid Matrix size: All rows and columns of a matrix must be the same size");

            _cols = columns;
            List<APLVariable> curRow = new List<APLVariable>();
            foreach(APLVariable v in items)
            {
                curRow.Add(v);
                if (curRow.Count == columns)
                {
                    _vals.Add(curRow);
                    curRow = new List<APLVariable>();
                }
            }
            if (curRow.Count != 0)
                _vals.Add(curRow);
        }

        /// <summary>
        /// Gets the variable type of this class
        /// </summary>
        /// <returns>VariableType.Matrix</returns>
        public new VariableType GetType()
        {
            return VariableType.Matrix;
        }

        /// <summary>
        /// The number of rows in this matrix
        /// </summary>
        public int Rows
        {
            get { return _vals.Count; }
        }

        /// <summary>
        /// The number of columns in this matrix
        /// </summary>
        public int Columns
        {
            get { return _cols; }
        }

        /// <summary>
        /// Add a row to this matrix
        /// </summary>
        /// <param name="v">list of values to add</param>
        public void AppendRow(List<APLVariable> v)
        {
            if (v.Count == _cols)
                _vals.Add(v);
            else
                throw new APLRuntimeError("Unable to add new row to matrix: All rows and columns of a matrix must be the same size");
        }

        /// <summary>
        /// Retrieve an element from this matrix
        /// </summary>
        /// <param name="row">row number of the element to extract (starts from 0)</param>
        /// <param name="column">column number of the element to extract (Starts from 0)</param>
        /// <returns>element specified by the row and column parameters</returns>
        public APLVariable this[int row, int column]
        {
            get
            {
                if (row >= _vals.Count || column >= _cols)
                    throw new APLRuntimeError("Invalid Matrix Item: The specified item does not exist within this matrix '" + row + "," + column + "'");

                return _vals[row][column];
            }
        }

        /// <summary>
        /// Return the number of items in this matrix
        /// </summary>
        public int Count
        {
            get { return _vals.Count*_cols; }
        }

        /// <summary>
        /// Provide raw access to the elements of this matrix
        /// </summary>
        public object Value
        {
            get
            {
                return _vals;
            }
            set
            {
                _vals = (List<List<APLVariable>>)value;
            }
        }

        /// <summary>
        /// Return the name of this matrix
        /// </summary>
        public string Name
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        /// <summary>
        /// Express this matrix as a string
        /// </summary>
        /// <returns>this matrix represented as a string</returns>
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();
            foreach (List<APLVariable> row in _vals)
            {
                sb.Append("[");
                StringBuilder cb = new StringBuilder();
                foreach (APLVariable col in row)
                {
                    cb.Append(col.ToString() + " ");
                }
                string rowstring = cb.ToString().TrimEnd();
                sb.Append(rowstring);
                sb.Append("]\n");
            }
            return sb.ToString();

        }

        /***
         * Static factory method
         ***/

        /// <summary>
        /// Take a string and create a matrix from it
        /// </summary>
        /// <param name="value">matrix as represented by a string</param>
        /// <returns>new matrix object</returns>
        public static APLMatrixVariable Parse(string value)
        {
            List<APLVariable> result = new List<APLVariable>();
            string cutStrign = value.Substring(1, value.Length - 2);
            string[] values = cutStrign.Split(new char[] {' '});
            foreach (String s in values)
            {
                result.Add(APLVariableFactory.GetVariable(s));
            }
            return new APLMatrixVariable(result, result.Count);
        }

        /// <summary>
        /// Create a touple (matrix with 1 row and 2 columns)
        /// </summary>
        /// <param name="v1">first column value</param>
        /// <param name="v2">second column value</param>
        /// <returns>new matrix object</returns>
        public static APLMatrixVariable ParseTuple(double v1, double v2)
        {
            List<APLVariable> result = new List<APLVariable>();
            result.Add(APLNumberVariable.Parse(v1));
            result.Add(APLNumberVariable.Parse(v2));
            return new APLMatrixVariable(result,result.Count);

        }

        /***
         * Basic Arithmetic Operations
         ***/

        // +
        public APLVariable Add(APLVariable arg)
        {
            switch (arg.GetType())
            {
                case VariableType.Number:
                    List<APLVariable> result = new List<APLVariable>();
                    for (int i = 0; i < this.Rows; i++)
                        for (int j = 0; j < this.Columns; j++)
                            result.Add(this[i,j].Add(arg));
                    return new APLMatrixVariable(result, this.Columns);

                case VariableType.Matrix:
                    APLMatrixVariable m_array = (APLMatrixVariable)arg;
                    if (m_array.Columns != this.Columns || m_array.Rows != this.Rows)
                        throw new APLRuntimeError("Matrix arguments to '+' must be of the same size");
                    List<APLVariable> m_result = new List<APLVariable>();
                    for (int i = 0; i < this.Rows; i++)
                        for (int j = 0; j < this.Columns; j++)
                            m_result.Add(this[i,j].Add(m_array[i,j]));
                    return new APLMatrixVariable(m_result,this.Columns);

                case VariableType.String:
                    List<APLVariable> s_result = new List<APLVariable>();
                    for (int i = 0; i < this.Rows; i++)
                        for (int j = 0; j < this.Columns; j++)
                            s_result.Add(this[i,j].Add(arg));
                    return new APLMatrixVariable(s_result, this.Columns);
                default:
                    throw new APLRuntimeError("Arguments to '+' are invalid");
            }

        }
        public APLVariable Add()
        {
            return this;
        }
        // -
        public APLVariable Subtract(APLVariable arg)
        {
            switch (arg.GetType())
            {
                case VariableType.Number:
                    List<APLVariable> result = new List<APLVariable>();
                    for (int i = 0; i < this.Rows; i++)
                        for (int j = 0; j < this.Columns; j++)
                            result.Add(this[i,j].Subtract(arg));
                    return new APLMatrixVariable(result, this.Columns);

                case VariableType.Matrix:
                    APLMatrixVariable m_array = (APLMatrixVariable)arg;
                    if (m_array.Columns != this.Columns || m_array.Rows != this.Rows)
                        throw new APLRuntimeError("Matrix arguments to '-' must be of the same size");
                    List<APLVariable> m_result = new List<APLVariable>();
                    for (int i = 0; i < this.Rows; i++)
                        for (int j = 0; j < this.Columns; j++)
                            m_result.Add(this[i,j].Subtract(m_array[i,j]));
                    return new APLMatrixVariable(m_result,this.Columns);

                case VariableType.String:
                    List<APLVariable> s_result = new List<APLVariable>();
                    for (int i = 0; i < this.Rows; i++)
                        for (int j = 0; j < this.Columns; j++)
                            s_result.Add(this[i,j].Subtract(arg));
                    return new APLMatrixVariable(s_result, this.Columns);
                default:
                    throw new APLRuntimeError("Arguments to '-' are invalid");
            }
        }
        public APLVariable Subtract()
        {
            List<APLVariable> var = new List<APLVariable>();
            for (int i = 0; i < this.Rows; i++)
                for (int j = 0; j < this.Columns; j++)
                    var.Add(this[i, j].Subtract());
            return new APLMatrixVariable(var, this.Columns);
        }
        //  x
        public APLVariable Multiply(APLVariable arg)
        {
            switch (arg.GetType())
            {
                case VariableType.Matrix:
                    APLMatrixVariable m_array = (APLMatrixVariable)arg;
                    if (m_array.Columns != this.Columns || m_array.Rows != this.Rows)
                        throw new APLRuntimeError("Matrix arguments to 'x' must be of the same size");
                    List<APLVariable> m_result = new List<APLVariable>();
                    for (int i = 0; i < this.Rows; i++)
                        for (int j = 0; j < this.Columns; j++)
                            m_result.Add(this[i,j].Multiply(m_array[i,j]));
                    return new APLMatrixVariable(m_result,this.Columns);

                default:
                    List<APLVariable> result = new List<APLVariable>();
                    for (int i = 0; i < this.Rows; i++)
                        for (int j = 0; j < this.Columns; j++)
                            result.Add(this[i,j].Multiply(arg));
                    return new APLMatrixVariable(result, this.Columns);
            }
        }
        public APLVariable Multiply()
        {
            List<APLVariable> var = new List<APLVariable>();
            for (int i = 0; i < this.Rows; i++)
                for (int j = 0; j < this.Columns; j++)
                    var.Add(this[i, j].Multiply());
            return new APLMatrixVariable(var, this.Columns);
        }
        //  %
        public APLVariable Divide(APLVariable arg)
        {
            switch (arg.GetType())
            {
                case VariableType.Matrix:
                    APLMatrixVariable m_array = (APLMatrixVariable)arg;
                    if (m_array.Columns != this.Columns || m_array.Rows != this.Rows)
                        throw new APLRuntimeError("Matrix arguments to '%' must be of the same size");
                    List<APLVariable> m_result = new List<APLVariable>();
                    for (int i = 0; i < this.Rows; i++)
                        for (int j = 0; j < this.Columns; j++)
                            m_result.Add(this[i,j].Divide(m_array[i,j]));
                    return new APLMatrixVariable(m_result,this.Columns);

                default:
                    List<APLVariable> result = new List<APLVariable>();
                    for (int i = 0; i < this.Rows; i++)
                        for (int j = 0; j < this.Columns; j++)
                            result.Add(this[i, j].Divide(arg));
                    return new APLMatrixVariable(result, this.Columns);
            }
        }
        public APLVariable Divide()
        {
            List<APLVariable> var = new List<APLVariable>();
            for (int i = 0; i < this.Rows; i++)
                for (int j = 0; j < this.Columns; j++)
                    var.Add(this[i, j].Divide());
            return new APLMatrixVariable(var, this.Columns);
        }
        // |
        public APLVariable Modulus(APLVariable arg)
        {
            switch (arg.GetType())
            {
                default:
                    List<APLVariable> result = new List<APLVariable>();
                    for (int i = 0; i < this.Rows; i++)
                        for (int j = 0; j < this.Columns; j++)
                            result.Add(this[i, j].Modulus(arg));
                    return new APLMatrixVariable(result, this.Columns);

                case VariableType.Matrix:
                    APLMatrixVariable m_array = (APLMatrixVariable)arg;
                    if (m_array.Columns != this.Columns || m_array.Rows != this.Rows)
                        throw new APLRuntimeError("Matrix arguments to '|' must be of the same size");
                    List<APLVariable> m_result = new List<APLVariable>();
                    for (int i = 0; i < this.Rows; i++)
                        for (int j = 0; j < this.Columns; j++)
                            m_result.Add(this[i, j].Modulus(m_array[i, j]));
                    return new APLMatrixVariable(m_result, this.Columns);
            }
        }
        public APLVariable Modulus()
        {
            List<APLVariable> var = new List<APLVariable>();
            for (int i = 0; i < this.Rows; i++)
                for (int j = 0; j < this.Columns; j++)
                    var.Add(this[i, j].Modulus());
            return new APLMatrixVariable(var, this.Columns);
        }
        //  bigger
        public APLVariable Bigger(APLVariable arg)
        {
            throw new NotImplementedException();
        }
        public APLVariable Bigger()
        {
            List<APLVariable> vars = new List<APLVariable>();
            for (int i = 0; i < this.Rows; i++)
                for (int j = 0; j < this.Columns; j++)
                    vars.Add(this[i, j].Bigger());
            return new APLMatrixVariable(vars, this.Columns);
        }
        //  smaller
        public APLVariable Smaller(APLVariable arg)
        {
            throw new NotImplementedException();
        }
        public APLVariable Smaller()
        {
            List<APLVariable> vars = new List<APLVariable>();
            for (int i = 0; i < this.Rows; i++)
                for (int j = 0; j < this.Columns; j++)
                    vars.Add(this[i, j].Smaller());
            return new APLMatrixVariable(vars, this.Columns);
        }
        //  biggest
        public APLVariable GreaterThan()
        {
            double biggest = -1;
            for (int i = 0; i < this.Rows; i++)
            {
                for (int j = 0; j < this.Columns; j++)
                {
                    if (biggest == -1 || (double)this[i,j].Value > biggest )
                        biggest = (double)this[i, j].Value;
                }
            }
            return APLNumberVariable.Parse(biggest);
        }
        public APLVariable GreaterThan(APLVariable arg)
        {
            switch (arg.GetType())
            {
                case VariableType.Number:
                    List<APLVariable> m_number = new List<APLVariable>();
                    for (int i = 0; i < this.Rows; i++)
                        for (int j = 0; j < this.Columns; j++)
                            m_number.Add(this[i, j].GreaterThan(arg));
                    return new APLMatrixVariable(m_number, this.Columns);
                default:
                    throw new APLRuntimeError("GT E");
            }

        }

        /***
         * Basic Algebraic Operations
         ***/
        public APLVariable Index(APLVariable arg)
        {
            switch (arg.GetType())
            {
                case VariableType.Matrix:
                    List<APLVariable> vars_m = new List<APLVariable>();
                    APLMatrixVariable m = (APLMatrixVariable)arg;
                    if (this.Rows != 1 || this.Columns != 2)
                        throw new APLRuntimeError("Unable to index into the matrix with the given parameters");

                    int r = (int)(double)this[0,0].Value;
                    int c = (int)(double)this[0,1].Value;
                    return m[r, c];
                default:
                    throw new APLRuntimeError("Unable to index into the matrix with the given parameters");
            }
        }
        public APLVariable Index()
        {
            throw new APLRuntimeError("The 'i' function does not operate on matrices");
        }

        //  @
        public APLVariable Outer(APLVariable arg)
        {
            return null;
        }
        //  TODO:   Implement Matrix Power
        public APLVariable Power(APLVariable arg)
        {
            VariableType tArg1 = this.GetType();
            VariableType tArg2 = arg.GetType();

            switch (tArg2)
            {
                case VariableType.Number:
                    List<APLVariable> nout = new List<APLVariable>();
                    for (int a = 0; a < this.Rows; a++)
                        for (int b = 0; b < this.Columns; b++)
                            nout.Add(this[a, b].Power(arg));
                    return new APLMatrixVariable(nout, this.Columns);
                case VariableType.Matrix:
                    APLMatrixVariable matArg = (APLMatrixVariable)arg;
                    if (matArg.Rows != this.Rows)
                        throw new APLRuntimeError("Unable to multiply matrices: Matrices must be of compatible dimensions in order to use the 'Multiply' function");
                    List<APLVariable> mout = new List<APLVariable>();
                    for (int a = 0; a < this.Rows; a++)
                        for (int b = 0; b < this.Columns; b++)
                            mout.Add(this[a, b].Power(matArg[a,b]));
                    return new APLMatrixVariable(mout, this.Columns);
                default:
                    throw new APLRuntimeError("Unsupported Arguments: The 'Multiply (*)' function does not support the arguments '" + this.GetType() + "' and '" + arg.GetType() + "'");
            }
        }
        //  TODO:   Implement
        public APLVariable Power()
        {
            throw new NotImplementedException();
        }
        //  TODO:   Implement
        public APLVariable NRoot(APLVariable arg)
        {
            throw new NotImplementedException();
        }

        public APLVariable Sqrt()
        {
            List<APLVariable> values = new List<APLVariable>();
            for (int i = 0; i < this.Rows; i++)
                for (int j = 0; j < this.Columns; j++)
                    values.Add(this[i, j].Sqrt());
            return new APLMatrixVariable(values, this.Columns);
        }
        //  TODO:   Implement
        public APLVariable Log(APLVariable arg)
        {
            throw new NotImplementedException();
        }
        //  TODO:   Implement
        public APLVariable Log()
        {
            throw new NotImplementedException();
        }
        public APLVariable Factorial()
        {
            List<APLVariable> vars = new List<APLVariable>();

            for (int i = 0; i < this.Rows; i++)
                for (int j = 0; j < this.Columns; j++)
                    vars.Add(this[i, j].Factorial());
            return new APLMatrixVariable(vars, this.Columns);

        }
        /// <summary>
        /// Resize a matrix by adjusting the column count
        /// </summary>
        /// <param name="colCount"></param>
        /// <returns></returns>
        public APLVariable Resize(APLVariable colCount)
        {
            switch (colCount.GetType())
            {
                /***
                 * When resizing an array with a numeric argument X
                 * The array is resized so that each row has X columns
                 ***/
                case VariableType.Number:
                    try
                    {
                        //  Set up internal variables for this case
                        int                 total = this.Rows * this.Columns;
                        int                 v     = Int32.Parse(colCount.Value.ToString());
                        List<APLVariable>   vals  = new List<APLVariable>();

                        //  Check that the resulting matrix will be of an allowed size
                        if ((this.Rows*this.Columns) % v != 0)
                            throw new APLRuntimeError("The parameters passed to the '#' function produce an invalid matrix size");

                        //  Add each variable to a new list
                        foreach (List<APLVariable> i in _vals)
                        {
                            foreach (APLVariable j in i)
                            {
                                vals.Add(j);
                            }
                        }

                        return new APLMatrixVariable(vals, (int)v);
                    }
                    catch (FormatException ex)
                    {
                        //  Catch non integer parameters (ie. decimal points)
                        throw new APLRuntimeError("The parameters passed to the '#' are invalid");
                    }
                /***
                 * When resizing an array with a array argument X
                 * The array is resized so that each row has X[0] columns
                 * and that X[1] rows exist
                 ***/
                case VariableType.Matrix:
                   APLMatrixVariable m = (APLMatrixVariable)colCount;
                   //Check that the argument has only 2 items in it

                   if (m.Columns != 2)
                       throw new APLRuntimeError("The '#' function only accepts two dimensions as an argument");

                   try
                   {
                       int drows = Int32.Parse(m[0, 1].Value.ToString());
                       int dcols = Int32.Parse(m[0, 0].Value.ToString());

                       //   Check that the matrix will be of the correct size
                       if ((_vals[0].Count / dcols) != drows)
                           throw new APLRuntimeError("The parameters passed to the '#' function produce an invalid matrix size");

                       List<APLVariable> mvals = new List<APLVariable>();
                       foreach (List<APLVariable> i in _vals)
                       {
                           foreach (APLVariable j in i)
                           {
                               mvals.Add(j);
                           }
                       }
                       return new APLMatrixVariable(mvals, dcols);
                   }
                   catch (FormatException ex)
                   {
                       //   Catch non integer array elements in argument
                       throw new APLRuntimeError("The parameters passed to the '#' are invalid");
                   }
                default:
                   throw new APLRuntimeError("The parameters passed to the '#' are invalid");
            }
        }

        /// <summary>
        /// Check if a matrix equals another matrix
        /// </summary>
        /// <param name="arg"></param>
        /// <returns></returns>
        public APLVariable Equals(APLVariable arg)
        {
            switch (arg.GetType())
            {
                case VariableType.Number:
                    List<APLVariable> vars = new List<APLVariable>();
                    for (int i = 0; i < this.Rows; i++)
                        for (int j = 0; j < this.Columns; j++)
                            vars.Add(this[i, j].Equals(arg));
                    return new APLMatrixVariable(vars, this.Columns);
                case VariableType.Matrix:
                    APLMatrixVariable var = (APLMatrixVariable)arg;
                    if (this.Columns != var.Columns || this.Rows != var.Rows)
                        throw new APLRuntimeError("The '=' function requires matrix arguments to be of the same size");

                    for (int i = 0; i < this.Rows; i++)
                        for (int j = 0; j < this.Columns; j++)
                            if (this[i, j].Equals(var[i, j]).Value.Equals(Interpreter.APL_FALSE.Value))
                                return Interpreter.APL_FALSE;
                    return Interpreter.APL_TRUE;
                default:
                    return Interpreter.APL_FALSE;
            }

        }

        /// <summary>
        /// Return the size of the matrix as a touple
        /// </summary>
        /// <returns></returns>
        public APLVariable Size()
        {
            return APLMatrixVariable.ParseTuple(this.Rows, this.Columns);

        }

        public APLVariable Find(APLVariable arg)
        {
            throw new NotImplementedException();
        }

        public int CompareTo(APLVariable other)
        {
            int val = 0;
            switch (other.GetType())
            {
                case VariableType.Matrix:
                    APLMatrixVariable m_var = (APLMatrixVariable) other;
                    if (m_var.Columns != this.Columns || m_var.Rows != this.Rows)
                        return -1;
                    for (int i = 0; i < this.Rows; i++)
                        for (int j = 0; j < this.Columns; j++)
                            val += this[i, j].CompareTo(m_var[i, j]);
                    return val;
                default:
                    return -1;
            }
        }

        public APLVariable Factorial(APLVariable arg)
        {
            throw new NotImplementedException();
        }

        public APLVariable Invert()
        {
            List<APLVariable> vals = new List<APLVariable>();

            for (int i = 0; i < this.Rows; i++)
                for (int j = 0; j < this.Columns; j++)
                    vals.Add(this[i, j].Invert());
            return new APLMatrixVariable(vals, this.Columns);
        }

        public APLVariable Invert(APLVariable arg)
        {
            throw new NotImplementedException();
        }

        public APLVariable GreaterEqThan(APLVariable arg)
        {
            throw new NotImplementedException();
        }

        public APLVariable GreaterEqThan()
        {
            throw new NotImplementedException();
        }

        public APLVariable LessThan(APLVariable arg)
        {
            throw new NotImplementedException();
        }

        public APLVariable LessThan()
        {
            throw new NotImplementedException();
        }

        public APLVariable LessEqThan(APLVariable arg)
        {
            throw new NotImplementedException();
        }

        public APLVariable LessEqThan()
        {
            throw new NotImplementedException();
        }
    }
}


text:
package org.powlab.jeye.tests.maps;

import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;

public class UntypedMapTest2 {
    private Map<?,?> memberMap = new TreeMap();

    public void test() {
        Map m = new HashMap();

        m.put("fred", 1);
        m.put(2, "fred");

        memberMap.putAll(m);
    }
}

redpajama_set_name: RedPajamaGithub


text:
package com.fincatto.documentofiscal.nfe400.classes;

import org.junit.Assert;
import org.junit.Test;

public class NFNotaMotivoDesoneracaoICMSTest {

    @Test
    public void deveObterMotivoDesoneracaoICMSApartirDoSeuCodigo() {
        Assert.assertEquals(NFNotaMotivoDesoneracaoICMS.TAXI, NFNotaMotivoDesoneracaoICMS.valueOfCodigo("1"));
        Assert.assertEquals(NFNotaMotivoDesoneracaoICMS.PRODUTOR_AGROPECUARIO, NFNotaMotivoDesoneracaoICMS.valueOfCodigo("3"));
        Assert.assertEquals(NFNotaMotivoDesoneracaoICMS.FROTISTA_LOCADORA, NFNotaMotivoDesoneracaoICMS.valueOfCodigo("4"));
        Assert.assertEquals(NFNotaMotivoDesoneracaoICMS.DIPLOMATICO_CONSULAR, NFNotaMotivoDesoneracaoICMS.valueOfCodigo("5"));
        Assert.assertEquals(NFNotaMotivoDesoneracaoICMS.UTILITARIOS_MOTOCICLETAS_AMAZONIA_OCIDENTAL_AREAS_LIVRE_COMERCIO, NFNotaMotivoDesoneracaoICMS.valueOfCodigo("6"));
        Assert.assertEquals(NFNotaMotivoDesoneracaoICMS.SUFRAMA, NFNotaMotivoDesoneracaoICMS.valueOfCodigo("7"));
        Assert.assertEquals(NFNotaMotivoDesoneracaoICMS.VENDA_ORGAOS_PUBLICOS, NFNotaMotivoDesoneracaoICMS.valueOfCodigo("8"));
        Assert.assertEquals(NFNotaMotivoDesoneracaoICMS.OUTROS, NFNotaMotivoDesoneracaoICMS.valueOfCodigo("9"));
        Assert.assertEquals(NFNotaMotivoDesoneracaoICMS.DEFICIENTE_CONDUTOR, NFNotaMotivoDesoneracaoICMS.valueOfCodigo("10"));
        Assert.assertEquals(NFNotaMotivoDesoneracaoICMS.DEFICIENTE_NAO_CONDUTOR, NFNotaMotivoDesoneracaoICMS.valueOfCodigo("11"));
        Assert.assertEquals(NFNotaMotivoDesoneracaoICMS.ORGAO_DE_FOMENTO_DESENVOLVIMENTO_AGROPECUARIO, NFNotaMotivoDesoneracaoICMS.valueOfCodigo("12"));
        Assert.assertNull(NFNotaMotivoDesoneracaoICMS.valueOfCodigo("0"));
    }

    @Test
    public void deveRepresentarOCodigoCorretamente() {
        Assert.assertEquals("1", NFNotaMotivoDesoneracaoICMS.TAXI.getCodigo());
        Assert.assertEquals("3", NFNotaMotivoDesoneracaoICMS.PRODUTOR_AGROPECUARIO.getCodigo());
        Assert.assertEquals("4", NFNotaMotivoDesoneracaoICMS.FROTISTA_LOCADORA.getCodigo());
        Assert.assertEquals("5", NFNotaMotivoDesoneracaoICMS.DIPLOMATICO_CONSULAR.getCodigo());
        Assert.assertEquals("6", NFNotaMotivoDesoneracaoICMS.UTILITARIOS_MOTOCICLETAS_AMAZONIA_OCIDENTAL_AREAS_LIVRE_COMERCIO.getCodigo());
        Assert.assertEquals("7", NFNotaMotivoDesoneracaoICMS.SUFRAMA.getCodigo());
        Assert.assertEquals("8", NFNotaMotivoDesoneracaoICMS.VENDA_ORGAOS_PUBLICOS.getCodigo());
        Assert.assertEquals("9", NFNotaMotivoDesoneracaoICMS.OUTROS.getCodigo());
        Assert.assertEquals("10", NFNotaMotivoDesoneracaoICMS.DEFICIENTE_CONDUTOR.getCodigo());
        Assert.assertEquals("11", NFNotaMotivoDesoneracaoICMS.DEFICIENTE_NAO_CONDUTOR.getCodigo());
        Assert.assertEquals("12", NFNotaMotivoDesoneracaoICMS.ORGAO_DE_FOMENTO_DESENVOLVIMENTO_AGROPECUARIO.getCodigo());
    }
}


text:
namespace gc {

void NurseryMemory::inc_nursery(BaseObject* ref) {
  if (nursery_.find(ref) != nursery_.end())
    record_objects_.push_back(ref);
}

void NurseryMemory::dec_nursery(BaseObject* ref) {
  if (nursery_.find(ref) != nursery_.end())
    record_objects_.remove(ref);
}

void NurseryMemory::write_pair(BaseObject* p, BaseObject* obj, bool is_first) {
  auto* pair = Chaos::down_cast<Pair*>(p);
  if (nursery_.find(p) == nursery_.end()) {
    inc_nursery(obj);
    if (is_first) {
      dec_nursery(pair->first());
      pair->set_first(obj);
    }
    else {
      dec_nursery(pair->second());
      pair->set_second(obj);
    }
  }
}

BaseObject* NurseryMemory::alloc(std::uint8_t type, std::size_t bytes) {
  auto alloc_fn = [this, type, bytes](void) -> BaseObject* {
    if (nursery_.size() >= kMaxObjects || objects_.size() >= kMaxObjects)
      return nullptr;

    void* p = Chaos::MemoryPool::get_instance().alloc(bytes);
    if (type == MemoryHeader::INT)
      return new (p) Int();
    else if (type == MemoryHeader::PAIR)
      return new (p) Pair();
    return nullptr;
  };

  auto* ref = alloc_fn();
  if (ref == nullptr) {
    collect_nursery();
    ref = alloc_fn();
    if (ref == nullptr) {
      collect();
      ref = alloc_fn();
      CHAOS_CHECK(ref != nullptr, "out of memory");
    }
  }

  nursery_.insert(ref);
  return ref;
}

void NurseryMemory::dealloc(BaseObject* obj) {
  Chaos::MemoryPool::get_instance().dealloc(obj);
}

void NurseryMemory::roots_nursery(void) {
  for (auto* obj : roots_) {
    if (nursery_.find(obj) != nursery_.end())
      record_objects_.push_back(obj);
  }
}

void NurseryMemory::scan_nursery(void) {
  while (!record_objects_.empty()) {
    auto* obj = record_objects_.back();
    record_objects_.pop_back();

    if (obj->inc_ref() == 1 && obj->is_pair()) {
      auto append_fn = [this](BaseObject* o) {
        if (o != nullptr && nursery_.find(o) != nursery_.end())
          record_objects_.push_back(o);
      };

      append_fn(Chaos::down_cast<Pair*>(obj)->first());
      append_fn(Chaos::down_cast<Pair*>(obj)->second());
    }
  }
}

void NurseryMemory::sweep_nursery(void) {
  for (auto* obj : nursery_) {
    if (obj->ref() == 0) {
      dealloc(obj);
    }
    else {
      obj->set_ref(0);
      objects_.push_back(obj);
    }
  }
  nursery_.clear();
}

void NurseryMemory::roots_tracing(std::stack<BaseObject*>& trace_objects) {
  for (auto* obj : roots_)
    trace_objects.push(obj);
}

void NurseryMemory::scan_tracing(std::stack<BaseObject*>& trace_objects) {
  while (!trace_objects.empty()) {
    auto* obj = trace_objects.top();
    trace_objects.pop();

    if (obj->inc_ref() == 1 && obj->is_pair()) {
      auto append_fn = [&trace_objects](BaseObject* o) {
        if (o != nullptr)
          trace_objects.push(o);
      };

      append_fn(Chaos::down_cast<Pair*>(obj)->first());
      append_fn(Chaos::down_cast<Pair*>(obj)->second());
    }
  }
}

void NurseryMemory::sweep_tracing(void) {
  for (auto it = objects_.begin(); it != objects_.end();) {
    if ((*it)->ref() == 0) {
      dealloc(*it);
      objects_.erase(it++);
    }
    else {
      (*it)->set_ref(0);
      ++it;
    }
  }
}

NurseryMemory& NurseryMemory::get_instance(void) {
  static NurseryMemory ins;
  return ins;
}

void NurseryMemory::collect_nursery(void) {
  auto old_count = nursery_.size();

  roots_nursery();
  scan_nursery();
  sweep_nursery();

  std::cout
    << "[" << old_count - nursery_.size() << "] nursery objects collected, "
    << "[" << nursery_.size() << "] nursery objects remaining. "
    << "[" << objects_.size() << "] objects remaining." << std::endl;
}

void NurseryMemory::collect(void) {
  auto old_count = objects_.size();

  std::stack<BaseObject*> trace_objects;
  roots_tracing(trace_objects);
  scan_tracing(trace_objects);
  sweep_tracing();

  std::cout
    << "[" << nursery_.size() << "] nursery objects remaining. "
    << "[" << old_count - objects_.size() << "] objects collected, "
    << "[" << objects_.size() << "] objects remaining." << std::endl;
}

BaseObject* NurseryMemory::put_in(int value) {
  auto* obj = Chaos::down_cast<Int*>(alloc(MemoryHeader::INT, sizeof(Int)));
  obj->set_value(value);

  roots_.push_back(obj);

  return obj;
}

BaseObject* NurseryMemory::put_in(BaseObject* first, BaseObject* second) {
  auto* obj = Chaos::down_cast<Pair*>(alloc(MemoryHeader::PAIR, sizeof(Pair)));
  if (first != nullptr)
    write_pair(obj, first, true);
  if (second != nullptr)
    write_pair(obj, second, false);

  roots_.push_back(obj);

  return obj;
}

BaseObject* NurseryMemory::fetch_out(void) {
  auto* obj = roots_.back();
  roots_.pop_back();
  return obj;
}

}


text:
#ifndef TCP_SOCKET_H
#define TCP_SOCKET_H

#include "uip.h"

struct tcp_socket;

typedef enum {
  TCP_SOCKET_CONNECTED,
  TCP_SOCKET_CLOSED,
  TCP_SOCKET_TIMEDOUT,
  TCP_SOCKET_ABORTED,
  TCP_SOCKET_DATA_SENT
} tcp_socket_event_t;

/**
 * \brief      TCP data callback function
 * \param s    A pointer to a TCP socket
 * \param ptr  A user-defined pointer
 * \param input_data_ptr A pointer to the incoming data
 * \param input_data_len The length of the incoming data
 * \return     The function should return the number of bytes to leave in the input buffer
 *
 *             The TCP socket input callback function gets
 *             called whenever there is new data on the socket. The
 *             function can choose to either consume the data
 *             directly, or leave it in the buffer for later. The
 *             function must return the amount of data to leave in the
 *             buffer. I.e., if the callback function consumes all
 *             incoming data, it should return 0.
 */
typedef int (* tcp_socket_data_callback_t)(struct tcp_socket *s,
                                           void *ptr,
                                           const uint8_t *input_data_ptr,
                                           int input_data_len);

/**
 * \brief      TCP event callback function
 * \param s    A pointer to a TCP socket
 * \param ptr  A user-defined pointer
 * \param event The event number
 *
 *             The TCP socket event callback function gets
 *             called whenever there is an event on a socket, such as
 *             the socket getting connected or closed.
 */
typedef void (* tcp_socket_event_callback_t)(struct tcp_socket *s,
                                             void *ptr,
                                             tcp_socket_event_t event);

struct tcp_socket {
  struct tcp_socket *next;

  tcp_socket_data_callback_t input_callback;
  tcp_socket_event_callback_t event_callback;
  void *ptr;

  struct process *p;

  uint8_t *input_data_ptr;
  uint8_t *output_data_ptr;

  uint16_t input_data_maxlen;
  uint16_t input_data_len;
  uint16_t output_data_maxlen;
  uint16_t output_data_len;
  uint16_t output_data_send_nxt;
  uint16_t output_senddata_len;
  uint16_t output_data_max_seg;

  uint8_t flags;
  uint16_t listen_port;
  struct uip_conn *c;
};

enum {
  TCP_SOCKET_FLAGS_NONE      = 0x00,
  TCP_SOCKET_FLAGS_LISTENING = 0x01,
  TCP_SOCKET_FLAGS_CLOSING   = 0x02,
};

/**
 * \brief      Register a TCP socket
 * \param s    A pointer to a TCP socket
 * \param ptr  A user-defined pointer that will be sent to callbacks for this socket
 * \param input_databuf A pointer to a memory area this socket will use for input data
 * \param input_databuf_len The size of the input data buffer
 * \param output_databuf A pointer to a memory area this socket will use for outgoing data
 * \param output_databuf_len The size of the output data buffer
 * \param data_callback A pointer to the data callback function for this socket
 * \param event_callback A pointer to the event callback function for this socket
 * \retval -1  If an error occurs
 * \retval 1   If the operation succeeds.
 *
 *             This function registers a TCP socket. The function sets
 *             up the output and input buffers for the socket and
 *             callback pointers.
 *
 *             TCP sockets use input and output buffers for incoming
 *             and outgoing data. The memory for these buffers must be
 *             allocated by the caller. The size of the buffers
 *             determine the amount of data that can be received and
 *             sent, and the principle is that the application that
 *             sets up the TCP socket will know roughly how large
 *             these buffers should be. The rule of thumb is that the
 *             input buffer should be large enough to hold the largest
 *             application layer message that the application will
 *             receive and the output buffer should be large enough to
 *             hold the largest application layer message the
 *             application will send.
 *
 *             TCP throttles incoming data so that if the input buffer
 *             is filled, the connection will halt until the
 *             application has read out the data from the input
 *             buffer.
 *
 */
int tcp_socket_register(struct tcp_socket *s, void *ptr,
                         uint8_t *input_databuf, int input_databuf_len,
                         uint8_t *output_databuf, int output_databuf_len,
                         tcp_socket_data_callback_t data_callback,
                         tcp_socket_event_callback_t event_callback);

/**
 * \brief      Connect a TCP socket to a remote host
 * \param s    A pointer to a TCP socket that must have been previously registered with tcp_socket_register()
 * \param ipaddr The IP address of the remote host
 * \param port The TCP port number, in host byte order, of the remote host
 * \retval -1  If an error occurs
 * \retval 1   If the operation succeeds.
 *
 *             This function connects a TCP socket to a remote host.
 *
 *             When the socket has connected, the event callback will
 *             get called with the TCP_SOCKET_CONNECTED event. If the
 *             remote host does not accept the connection, the
 *             TCP_SOCKET_ABORTED will be sent to the callback. If the
 *             connection times out before conecting to the remote
 *             host, the TCP_SOCKET_TIMEDOUT event is sent to the
 *             callback.
 *
 */
int tcp_socket_connect(struct tcp_socket *s,
                       const uip_ipaddr_t *ipaddr,
                       uint16_t port);

/**
 * \brief      Start listening on a specific port
 * \param s    A pointer to a TCP socket that must have been previously registered with tcp_socket_register()
 * \param port The TCP port number, in host byte order, of the remote host
 * \retval -1  If an error occurs
 * \retval 1   If the operation succeeds.
 *
 *             This function causes the TCP socket to start listening
 *             on the given TCP port.
 *
 *             Several sockets can listen on the same port. If a
 *             remote host connects to the port, one of the listening
 *             sockets will get connected and the event callback will
 *             be called with the TCP_SOCKET_CONNECTED event. When the
 *             connection closes, the socket will go back to listening
 *             for new connections.
 *
 */
int tcp_socket_listen(struct tcp_socket *s,
                      uint16_t port);

/**
 * \brief      Stop listening for new connections
 * \param s    A pointer to a TCP socket that must have been previously registered with tcp_socket_register()
 * \retval -1  If an error occurs
 * \retval 1   If the operation succeeds.
 *
 *             This function causes a listening TCP socket to stop
 *             listen. The socket must previously been put into listen
 *             mode with tcp_socket_listen().
 *
 */
int tcp_socket_unlisten(struct tcp_socket *s);

/**
 * \brief      Send data on a connected TCP socket
 * \param s    A pointer to a TCP socket that must have been previously registered with tcp_socket_register()
 * \param dataptr A pointer to the data to be sent
 * \param datalen The length of the data to be sent
 * \retval -1  If an error occurs
 * \return     The number of bytes that were successfully sent
 *
 *             This function sends data over a connected TCP
 *             socket. The data is placed in the output buffer and
 *             sent to the remote host as soon as possiblce. When the
 *             data has been acknowledged by the remote host, the
 *             event callback is sent with the TCP_SOCKET_DATA_SENT
 *             event.
 */
int tcp_socket_send(struct tcp_socket *s,
                    const uint8_t *dataptr,
                    int datalen);

/**
 * \brief      Send a string on a connected TCP socket
 * \param s    A pointer to a TCP socket that must have been previously registered with tcp_socket_register()
 * \param strptr A pointer to the string to be sent
 * \retval -1  If an error occurs
 * \return     The number of bytes that were successfully sent
 *
 *             This is a convenience function for sending strings on a
 *             TCP socket. The function calls tcp_socket_send() to
 *             send the string.
 */
int tcp_socket_send_str(struct tcp_socket *s,
                        const char *strptr);

/**
 * \brief      Close a connected TCP socket
 * \param s    A pointer to a TCP socket that must have been previously registered with tcp_socket_register()
 * \retval -1  If an error occurs
 * \retval 1   If the operation succeeds.
 *
 *             This function closes a connected TCP socket. When the
 *             socket has been successfully closed, the event callback
 *             is called with the TCP_SOCKET_CLOSED event.
 *
 */
int tcp_socket_close(struct tcp_socket *s);

/**
 * \brief      Unregister a registered socket
 * \param s    A pointer to a TCP socket that must have been previously registered with tcp_socket_register()
 * \retval -1  If an error occurs
 * \retval 1   If the operation succeeds.
 *
 *             This function unregisters a previously registered
 *             socket. This must be done if the process will be
 *             unloaded from memory. If the TCP socket is connected,
 *             the connection will be reset.
 *
 */
int tcp_socket_unregister(struct tcp_socket *s);

/**
 * \brief      The maximum amount of data that could currently be sent
 * \param s    A pointer to a TCP socket
 * \return     The number of bytes available in the output buffer
 *
 *             This function queries the TCP socket and returns the
 *             number of bytes available in the output buffer. This
 *             function is used before calling tcp_socket_send() to
 *             ensure that one application level message can be held
 *             in the output buffer.
 *
 */
int tcp_socket_max_sendlen(struct tcp_socket *s);

/**
 * \brief      The number of bytes waiting to be sent
 * \param s    A pointer to a TCP socket
 * \return     The number of bytes that have not yet been acknowledged by the receiver.
 *
 *             This function queries the TCP socket and returns the
 *             number of bytes that are currently not yet known to
 *             have been successfully received by the receiver.
 *
 */
int tcp_socket_queuelen(struct tcp_socket *s);

#endif /* TCP_SOCKET_H */


text:
//-----------------------------------------------------------------------
// <copyright file="NotUsed.cs" company="Akka.NET Project">
//     Copyright (C) 2009-2020 Lightbend Inc. <http://www.lightbend.com>
//     Copyright (C) 2013-2020 .NET Foundation <https://github.com/akkadotnet/akka.net>
// </copyright>
//-----------------------------------------------------------------------

using System;

namespace Akka
{
    /// <summary>
    /// This type is used in generic type signatures wherever the actual value is of no importance.
    /// It is a combination of F#'s 'unit' and C#'s 'void', which both have different issues when
    /// used from the other language. An example use-case is the materialized value of an Akka Stream for cases
    /// where no result shall be returned from materialization.
    /// </summary>
    [Serializable]
    public sealed class NotUsed : IEquatable<NotUsed>, IComparable<NotUsed>
    {
        /// <summary>
        /// The singleton instance of <see cref="NotUsed"/>.
        /// </summary>
        public static readonly NotUsed Instance = new NotUsed();

        private NotUsed()
        {
        }

        /// <inheritdoc/>
        public override int GetHashCode()
        {
            return 0;
        }

        /// <inheritdoc/>
        public override bool Equals(object obj)
        {
            return obj is NotUsed;
        }

        /// <inheritdoc/>
        public override string ToString()
        {
            return "()";
        }

        /// <inheritdoc/>
        public bool Equals(NotUsed other)
        {
            return true;
        }

        /// <inheritdoc/>
        public int CompareTo(NotUsed other)
        {
            return 0;
        }
    }
}


text:
void ATWebClient_Private_Bootstrap() {
	NSLog(@"Loading ATWebClient_Private_Bootstrap");
}


text:
/*	$NetBSD: Locore.c,v 1.7 2000/08/20 07:04:59 tsubai Exp $	*/

/*-
 * Copyright (C) 1995, 1996 Wolfgang Solfrank.
 * Copyright (C) 1995, 1996 TooLs GmbH.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *	This product includes software developed by TooLs GmbH.
 * 4. The name of TooLs GmbH may not be used to endorse or promote products
 *    derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
/*-
 * Copyright (C) 2000 Benno Rice.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY Benno Rice ``AS IS'' AND ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");

#include "opt_platform.h"

#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/mutex.h>
#include <sys/queue.h>
#include <sys/systm.h>
#include <sys/endian.h>

#include <machine/stdarg.h>

#include <dev/ofw/ofwvar.h>
#include <dev/ofw/openfirm.h>

#include "ofw_if.h"

static void OF_putchar(int c, void *arg);

MALLOC_DEFINE(M_OFWPROP, "openfirm", "Open Firmware properties");

static ihandle_t stdout;

static ofw_def_t	*ofw_def_impl = NULL;
static ofw_t		ofw_obj;
static struct ofw_kobj	ofw_kernel_obj;
static struct kobj_ops	ofw_kernel_kops;

struct xrefinfo {
	phandle_t	xref;
	phandle_t 	node;
	device_t  	dev;
	SLIST_ENTRY(xrefinfo) next_entry;
};

static SLIST_HEAD(, xrefinfo) xreflist = SLIST_HEAD_INITIALIZER(xreflist);
static struct mtx xreflist_lock;
static boolean_t xref_init_done;

#define	FIND_BY_XREF	0
#define	FIND_BY_NODE	1
#define	FIND_BY_DEV	2

/*
 * xref-phandle-device lookup helper routines.
 *
 * As soon as we are able to use malloc(), walk the node tree and build a list
 * of info that cross-references node handles, xref handles, and device_t
 * instances.  This list exists primarily to allow association of a device_t
 * with an xref handle, but it is also used to speed up translation between xref
 * and node handles.  Before malloc() is available we have to recursively search
 * the node tree each time we want to translate between a node and xref handle.
 * Afterwards we can do the translations by searching this much shorter list.
 */
static void
xrefinfo_create(phandle_t node)
{
	struct xrefinfo * xi;
	phandle_t child, xref;

	/*
	 * Recursively descend from parent, looking for nodes with a property
	 * named either "phandle", "ibm,phandle", or "linux,phandle".  For each
	 * such node found create an entry in the xreflist.
	 */
	for (child = OF_child(node); child != 0; child = OF_peer(child)) {
		xrefinfo_create(child);
		if (OF_getencprop(child, "phandle", &xref, sizeof(xref)) ==
		    -1 && OF_getencprop(child, "ibm,phandle", &xref,
		    sizeof(xref)) == -1 && OF_getencprop(child,
		    "linux,phandle", &xref, sizeof(xref)) == -1)
			continue;
		xi = malloc(sizeof(*xi), M_OFWPROP, M_WAITOK | M_ZERO);
		xi->node = child;
		xi->xref = xref;
		SLIST_INSERT_HEAD(&xreflist, xi, next_entry);
	}
}

static void
xrefinfo_init(void *unsed)
{

	/*
	 * There is no locking during this init because it runs much earlier
	 * than any of the clients/consumers of the xref list data, but we do
	 * initialize the mutex that will be used for access later.
	 */
	mtx_init(&xreflist_lock, "OF xreflist lock", NULL, MTX_DEF);
	xrefinfo_create(OF_peer(0));
	xref_init_done = true;
}
SYSINIT(xrefinfo, SI_SUB_KMEM, SI_ORDER_ANY, xrefinfo_init, NULL);

static struct xrefinfo *
xrefinfo_find(uintptr_t key, int find_by)
{
	struct xrefinfo *rv, *xi;

	rv = NULL;
	mtx_lock(&xreflist_lock);
	SLIST_FOREACH(xi, &xreflist, next_entry) {
		if ((find_by == FIND_BY_XREF && (phandle_t)key == xi->xref) ||
		    (find_by == FIND_BY_NODE && (phandle_t)key == xi->node) ||
		    (find_by == FIND_BY_DEV && key == (uintptr_t)xi->dev)) {
			rv = xi;
			break;
		}
	}
	mtx_unlock(&xreflist_lock);
	return (rv);
}

static struct xrefinfo *
xrefinfo_add(phandle_t node, phandle_t xref, device_t dev)
{
	struct xrefinfo *xi;

	xi = malloc(sizeof(*xi), M_OFWPROP, M_WAITOK);
	xi->node = node;
	xi->xref = xref;
	xi->dev  = dev;
	mtx_lock(&xreflist_lock);
	SLIST_INSERT_HEAD(&xreflist, xi, next_entry);
	mtx_unlock(&xreflist_lock);
	return (xi);
}

/*
 * OFW install routines.  Highest priority wins, equal priority also
 * overrides allowing last-set to win.
 */
SET_DECLARE(ofw_set, ofw_def_t);

boolean_t
OF_install(char *name, int prio)
{
	ofw_def_t *ofwp, **ofwpp;
	static int curr_prio = 0;

	/*
	 * Try and locate the OFW kobj corresponding to the name.
	 */
	SET_FOREACH(ofwpp, ofw_set) {
		ofwp = *ofwpp;

		if (ofwp->name &&
		    !strcmp(ofwp->name, name) &&
		    prio >= curr_prio) {
			curr_prio = prio;
			ofw_def_impl = ofwp;
			return (TRUE);
		}
	}

	return (FALSE);
}

/* Initializer */
int
OF_init(void *cookie)
{
	phandle_t chosen;
	int rv;

	if (ofw_def_impl == NULL)
		return (-1);

	ofw_obj = &ofw_kernel_obj;
	/*
	 * Take care of compiling the selected class, and
	 * then statically initialize the OFW object.
	 */
	kobj_class_compile_static(ofw_def_impl, &ofw_kernel_kops);
	kobj_init_static((kobj_t)ofw_obj, ofw_def_impl);

	rv = OFW_INIT(ofw_obj, cookie);

	if ((chosen = OF_finddevice("/chosen")) != -1)
		if (OF_getencprop(chosen, "stdout", &stdout,
		    sizeof(stdout)) == -1)
			stdout = -1;

	return (rv);
}

static void
OF_putchar(int c, void *arg __unused)
{
	char cbuf;

	if (c == '\n') {
		cbuf = '\r';
		OF_write(stdout, &cbuf, 1);
	}

	cbuf = c;
	OF_write(stdout, &cbuf, 1);
}

void
OF_printf(const char *fmt, ...)
{
	va_list	va;

	va_start(va, fmt);
	(void)kvprintf(fmt, OF_putchar, NULL, 10, va);
	va_end(va);
}

/*
 * Generic functions
 */

/* Test to see if a service exists. */
int
OF_test(const char *name)
{

	if (ofw_def_impl == NULL)
		return (-1);

	return (OFW_TEST(ofw_obj, name));
}

int
OF_interpret(const char *cmd, int nreturns, ...)
{
	va_list ap;
	cell_t slots[16];
	int i = 0;
	int status;

	if (ofw_def_impl == NULL)
		return (-1);

	status = OFW_INTERPRET(ofw_obj, cmd, nreturns, slots);
	if (status == -1)
		return (status);

	va_start(ap, nreturns);
	while (i < nreturns)
		*va_arg(ap, cell_t *) = slots[i++];
	va_end(ap);

	return (status);
}

/*
 * Device tree functions
 */

/* Return the next sibling of this node or 0. */
phandle_t
OF_peer(phandle_t node)
{

	if (ofw_def_impl == NULL)
		return (0);

	return (OFW_PEER(ofw_obj, node));
}

/* Return the first child of this node or 0. */
phandle_t
OF_child(phandle_t node)
{

	if (ofw_def_impl == NULL)
		return (0);

	return (OFW_CHILD(ofw_obj, node));
}

/* Return the parent of this node or 0. */
phandle_t
OF_parent(phandle_t node)
{

	if (ofw_def_impl == NULL)
		return (0);

	return (OFW_PARENT(ofw_obj, node));
}

/* Return the package handle that corresponds to an instance handle. */
phandle_t
OF_instance_to_package(ihandle_t instance)
{

	if (ofw_def_impl == NULL)
		return (-1);

	return (OFW_INSTANCE_TO_PACKAGE(ofw_obj, instance));
}

/* Get the length of a property of a package. */
ssize_t
OF_getproplen(phandle_t package, const char *propname)
{

	if (ofw_def_impl == NULL)
		return (-1);

	return (OFW_GETPROPLEN(ofw_obj, package, propname));
}

/* Check existence of a property of a package. */
int
OF_hasprop(phandle_t package, const char *propname)
{

	return (OF_getproplen(package, propname) >= 0 ? 1 : 0);
}

/* Get the value of a property of a package. */
ssize_t
OF_getprop(phandle_t package, const char *propname, void *buf, size_t buflen)
{

	if (ofw_def_impl == NULL)
		return (-1);

	return (OFW_GETPROP(ofw_obj, package, propname, buf, buflen));
}

ssize_t
OF_getencprop(phandle_t node, const char *propname, pcell_t *buf, size_t len)
{
	ssize_t retval;
	int i;

	KASSERT(len % 4 == 0, ("Need a multiple of 4 bytes"));

	retval = OF_getprop(node, propname, buf, len);
	for (i = 0; i < len/4; i++)
		buf[i] = be32toh(buf[i]);

	return (retval);
}

/*
 * Recursively search the node and its parent for the given property, working
 * downward from the node to the device tree root.  Returns the value of the
 * first match.
 */
ssize_t
OF_searchprop(phandle_t node, const char *propname, void *buf, size_t len)
{
	ssize_t rv;

	for (; node != 0; node = OF_parent(node))
		if ((rv = OF_getprop(node, propname, buf, len)) != -1)
			return (rv);
	return (-1);
}

ssize_t
OF_searchencprop(phandle_t node, const char *propname, void *buf, size_t len)
{
	ssize_t rv;

	for (; node != 0; node = OF_parent(node))
		if ((rv = OF_getencprop(node, propname, buf, len)) != -1)
			return (rv);
	return (-1);
}

/*
 * Store the value of a property of a package into newly allocated memory
 * (using the M_OFWPROP malloc pool and M_WAITOK).  elsz is the size of a
 * single element, the number of elements is return in number.
 */
ssize_t
OF_getprop_alloc(phandle_t package, const char *propname, int elsz, void **buf)
{
	int len;

	*buf = NULL;
	if ((len = OF_getproplen(package, propname)) == -1 ||
	    len % elsz != 0)
		return (-1);

	*buf = malloc(len, M_OFWPROP, M_WAITOK);
	if (OF_getprop(package, propname, *buf, len) == -1) {
		free(*buf, M_OFWPROP);
		*buf = NULL;
		return (-1);
	}
	return (len / elsz);
}

ssize_t
OF_getencprop_alloc(phandle_t package, const char *name, int elsz, void **buf)
{
	ssize_t retval;
	pcell_t *cell;
	int i;

	retval = OF_getprop_alloc(package, name, elsz, buf);
	if (retval == -1 || retval*elsz % 4 != 0)
		return (-1);

	cell = *buf;
	for (i = 0; i < retval*elsz/4; i++)
		cell[i] = be32toh(cell[i]);

	return (retval);
}

/* Get the next property of a package. */
int
OF_nextprop(phandle_t package, const char *previous, char *buf, size_t size)
{

	if (ofw_def_impl == NULL)
		return (-1);

	return (OFW_NEXTPROP(ofw_obj, package, previous, buf, size));
}

/* Set the value of a property of a package. */
int
OF_setprop(phandle_t package, const char *propname, const void *buf, size_t len)
{

	if (ofw_def_impl == NULL)
		return (-1);

	return (OFW_SETPROP(ofw_obj, package, propname, buf,len));
}

/* Convert a device specifier to a fully qualified pathname. */
ssize_t
OF_canon(const char *device, char *buf, size_t len)
{

	if (ofw_def_impl == NULL)
		return (-1);

	return (OFW_CANON(ofw_obj, device, buf, len));
}

/* Return a package handle for the specified device. */
phandle_t
OF_finddevice(const char *device)
{

	if (ofw_def_impl == NULL)
		return (-1);

	return (OFW_FINDDEVICE(ofw_obj, device));
}

/* Return the fully qualified pathname corresponding to an instance. */
ssize_t
OF_instance_to_path(ihandle_t instance, char *buf, size_t len)
{

	if (ofw_def_impl == NULL)
		return (-1);

	return (OFW_INSTANCE_TO_PATH(ofw_obj, instance, buf, len));
}

/* Return the fully qualified pathname corresponding to a package. */
ssize_t
OF_package_to_path(phandle_t package, char *buf, size_t len)
{

	if (ofw_def_impl == NULL)
		return (-1);

	return (OFW_PACKAGE_TO_PATH(ofw_obj, package, buf, len));
}

/* Look up effective phandle (see FDT/PAPR spec) */
static phandle_t
OF_child_xref_phandle(phandle_t parent, phandle_t xref)
{
	phandle_t child, rxref;

	/*
	 * Recursively descend from parent, looking for a node with a property
	 * named either "phandle", "ibm,phandle", or "linux,phandle" that
	 * matches the xref we are looking for.
	 */

	for (child = OF_child(parent); child != 0; child = OF_peer(child)) {
		rxref = OF_child_xref_phandle(child, xref);
		if (rxref != -1)
			return (rxref);

		if (OF_getencprop(child, "phandle", &rxref, sizeof(rxref)) ==
		    -1 && OF_getencprop(child, "ibm,phandle", &rxref,
		    sizeof(rxref)) == -1 && OF_getencprop(child,
		    "linux,phandle", &rxref, sizeof(rxref)) == -1)
			continue;

		if (rxref == xref)
			return (child);
	}

	return (-1);
}

phandle_t
OF_node_from_xref(phandle_t xref)
{
	struct xrefinfo *xi;
	phandle_t node;

	if (xref_init_done) {
		if ((xi = xrefinfo_find(xref, FIND_BY_XREF)) == NULL)
			return (xref);
		return (xi->node);
	}

	if ((node = OF_child_xref_phandle(OF_peer(0), xref)) == -1)
		return (xref);
	return (node);
}

phandle_t
OF_xref_from_node(phandle_t node)
{
	struct xrefinfo *xi;
	phandle_t xref;

	if (xref_init_done) {
		if ((xi = xrefinfo_find(node, FIND_BY_NODE)) == NULL)
			return (node);
		return (xi->xref);
	}

	if (OF_getencprop(node, "phandle", &xref, sizeof(xref)) ==
	    -1 && OF_getencprop(node, "ibm,phandle", &xref,
	    sizeof(xref)) == -1 && OF_getencprop(node,
	    "linux,phandle", &xref, sizeof(xref)) == -1)
		return (node);
	return (xref);
}

device_t
OF_device_from_xref(phandle_t xref)
{
	struct xrefinfo *xi;

	if (xref_init_done) {
		if ((xi = xrefinfo_find(xref, FIND_BY_XREF)) == NULL)
			return (NULL);
		return (xi->dev);
	}
	panic("Attempt to find device before xreflist_init");
}

phandle_t
OF_xref_from_device(device_t dev)
{
	struct xrefinfo *xi;

	if (xref_init_done) {
		if ((xi = xrefinfo_find((uintptr_t)dev, FIND_BY_DEV)) == NULL)
			return (0);
		return (xi->xref);
	}
	panic("Attempt to find xref before xreflist_init");
}

int
OF_device_register_xref(phandle_t xref, device_t dev)
{
	struct xrefinfo *xi;

	/*
	 * If the given xref handle doesn't already exist in the list then we
	 * add a list entry.  In theory this can only happen on a system where
	 * nodes don't contain phandle properties and xref and node handles are
	 * synonymous, so the xref handle is added as the node handle as well.
	 */
	if (xref_init_done) {
		if ((xi = xrefinfo_find(xref, FIND_BY_XREF)) == NULL)
			xrefinfo_add(xref, xref, dev);
		else
			xi->dev = dev;
		return (0);
	}
	panic("Attempt to register device before xreflist_init");
}

/*  Call the method in the scope of a given instance. */
int
OF_call_method(const char *method, ihandle_t instance, int nargs, int nreturns,
    ...)
{
	va_list ap;
	cell_t args_n_results[12];
	int n, status;

	if (nargs > 6 || ofw_def_impl == NULL)
		return (-1);
	va_start(ap, nreturns);
	for (n = 0; n < nargs; n++)
		args_n_results[n] = va_arg(ap, cell_t);

	status = OFW_CALL_METHOD(ofw_obj, instance, method, nargs, nreturns,
	    args_n_results);
	if (status != 0)
		return (status);

	for (; n < nargs + nreturns; n++)
		*va_arg(ap, cell_t *) = args_n_results[n];
	va_end(ap);
	return (0);
}

/*
 * Device I/O functions
 */

/* Open an instance for a device. */
ihandle_t
OF_open(const char *device)
{

	if (ofw_def_impl == NULL)
		return (0);

	return (OFW_OPEN(ofw_obj, device));
}

/* Close an instance. */
void
OF_close(ihandle_t instance)
{

	if (ofw_def_impl == NULL)
		return;

	OFW_CLOSE(ofw_obj, instance);
}

/* Read from an instance. */
ssize_t
OF_read(ihandle_t instance, void *addr, size_t len)
{

	if (ofw_def_impl == NULL)
		return (-1);

	return (OFW_READ(ofw_obj, instance, addr, len));
}

/* Write to an instance. */
ssize_t
OF_write(ihandle_t instance, const void *addr, size_t len)
{

	if (ofw_def_impl == NULL)
		return (-1);

	return (OFW_WRITE(ofw_obj, instance, addr, len));
}

/* Seek to a position. */
int
OF_seek(ihandle_t instance, uint64_t pos)
{

	if (ofw_def_impl == NULL)
		return (-1);

	return (OFW_SEEK(ofw_obj, instance, pos));
}

/*
 * Memory functions
 */

/* Claim an area of memory. */
void *
OF_claim(void *virt, size_t size, u_int align)
{

	if (ofw_def_impl == NULL)
		return ((void *)-1);

	return (OFW_CLAIM(ofw_obj, virt, size, align));
}

/* Release an area of memory. */
void
OF_release(void *virt, size_t size)
{

	if (ofw_def_impl == NULL)
		return;

	OFW_RELEASE(ofw_obj, virt, size);
}

/*
 * Control transfer functions
 */

/* Suspend and drop back to the Open Firmware interface. */
void
OF_enter()
{

	if (ofw_def_impl == NULL)
		return;

	OFW_ENTER(ofw_obj);
}

/* Shut down and drop back to the Open Firmware interface. */
void
OF_exit()
{

	if (ofw_def_impl == NULL)
		panic("OF_exit: Open Firmware not available");

	/* Should not return */
	OFW_EXIT(ofw_obj);

	for (;;)			/* just in case */
		;
}


text:
package conf

import (
	"testing"

	"github.com/stretchr/testify/assert"
)

func TestCheckFormatServerConf(t *testing.T) {
	type TestData struct {
		desc   string
		c      Config
		expect bool
	}
	tds := []TestData{
		{
			desc: "Address, user and password",
			c: Config{
				Server: map[string]ServerConfig{
					"a": ServerConfig{Addr: "192.168.100.101", User: "test", Pass: "Password"},
				},
			},
			expect: true,
		},
		{
			desc: "Empty address",
			c: Config{
				Server: map[string]ServerConfig{
					"b": ServerConfig{Addr: "", User: "test", Pass: "Password"},
				},
			},
			expect: false,
		},
		{
			desc: "Empty user",
			c: Config{
				Server: map[string]ServerConfig{
					"c": ServerConfig{Addr: "192.168.100.101", User: "", Pass: "Password"},
				},
			},
			expect: false,
		},
		{
			desc: "Empty password",
			c: Config{
				Server: map[string]ServerConfig{
					"d": ServerConfig{Addr: "192.168.100.101", User: "test", Pass: ""},
				},
			},
			expect: false,
		},
		{
			desc: "1 server config is illegal",
			c: Config{
				Server: map[string]ServerConfig{
					"a": ServerConfig{Addr: "192.168.100.101", User: "test", Pass: "Password"},
					"b": ServerConfig{Addr: "", User: "test", Pass: "Password"},
					"e": ServerConfig{Addr: "192.168.100.101", User: "test", Pass: "Password"},
				},
			},
			expect: false,
		},
	}
	for _, v := range tds {
		got := v.c.checkFormatServerConf()
		assert.Equal(t, v.expect, got, v.desc)
	}
}

func TestCheckFormatServerConfAuth(t *testing.T) {
	type TestData struct {
		desc   string
		c      ServerConfig
		expect bool
	}
	tds := []TestData{
		{desc: "Password", c: ServerConfig{Pass: "Password"}, expect: true},
		{desc: "Secret key file", c: ServerConfig{Key: "/tmp/key.pem"}, expect: true},
		{desc: "Cert file", c: ServerConfig{Cert: "/tmp/key.crt"}, expect: true},
		{desc: "Agent auth", c: ServerConfig{AgentAuth: true}, expect: true},
		// {desc: "File exists", c: ServerConfig{PKCS11Provider: "/path/to/providor"}, expect: true},
		{desc: "Key files", c: ServerConfig{Keys: []string{"/tmp/key.pem", "/tmp/key2.pem"}}, expect: true},
		{desc: "Passwords", c: ServerConfig{Passes: []string{"Pass1", "Pass2"}}, expect: true},
	}
	for _, v := range tds {
		got := checkFormatServerConfAuth(v.c)
		assert.Equal(t, v.expect, got, v.desc)
	}
}

func TestServerConfigReduct(t *testing.T) {
	type TestData struct {
		desc                   string
		perConfig, childConfig ServerConfig
		expect                 ServerConfig
	}
	tds := []TestData{
		{
			desc:        "Set perConfig addr to child config",
			perConfig:   ServerConfig{Addr: "192.168.100.101", User: "pertest"},
			childConfig: ServerConfig{User: "test"},
			expect:      ServerConfig{Addr: "192.168.100.101", User: "test"},
		},
		{
			desc:        "Child config is empty",
			perConfig:   ServerConfig{Addr: "192.168.100.101"},
			childConfig: ServerConfig{},
			expect:      ServerConfig{Addr: "192.168.100.101"},
		},
		{
			desc:        "Per config is empty",
			perConfig:   ServerConfig{},
			childConfig: ServerConfig{User: "test"},
			expect:      ServerConfig{User: "test"},
		},
		{
			desc:        "Both empty",
			perConfig:   ServerConfig{},
			childConfig: ServerConfig{},
			expect:      ServerConfig{},
		},
	}
	for _, v := range tds {
		got := serverConfigReduct(v.perConfig, v.childConfig)
		assert.Equal(t, v.expect, got, v.desc)
	}
}

func TestGetNameList(t *testing.T) {
	type TestData struct {
		desc     string
		listConf Config
		expect   []string
	}
	tds := []TestData{
		{
			desc: "",
			listConf: Config{
				Server: map[string]ServerConfig{
					"a": ServerConfig{},
					"b": ServerConfig{},
				},
			},
			expect: []string{"a", "b"},
		},
		{
			desc: "",
			listConf: Config{
				Server: map[string]ServerConfig{},
			},
			expect: nil,
		},
	}
	for _, v := range tds {
		got := GetNameList(v.listConf)
		assert.Equal(t, v.expect, got, v.desc)
	}
}


text:
<?php
namespace Thrace\FormBundle\Tests\Validator\Constraint;

use Thrace\FormBundle\Validator\Constraint\Recaptcha;

use Thrace\ComponentBundle\Test\Tool\BaseTestCase;

class RecaptchaTest extends BaseTestCase
{

    public function testDefault()
    {
        $constraint = new Recaptcha(array('emptyMessage' => 'empty', 'invalidMessage' => 'invalid'));

        $this->assertSame('empty', $constraint->emptyMessage);
        $this->assertSame('invalid', $constraint->invalidMessage);
        $this->assertSame('thrace_form_recaptcha_validator', $constraint->validatedBy());
    }

}


text:
// Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

package org.chromium.chrome.browser.feed.webfeed;

import android.view.View;

import org.chromium.base.Callback;
import org.chromium.ui.modaldialog.DialogDismissalCause;
import org.chromium.ui.modaldialog.ModalDialogManager;
import org.chromium.ui.modaldialog.ModalDialogProperties;
import org.chromium.ui.modelutil.PropertyModel;

/**
 * Mediator class responsible for the logic of showing WebFeed dialogs.
 */
class WebFeedDialogMediator {
    private final ModalDialogManager mDialogManager;

    private PropertyModel mHostDialogModel;

    private class DialogClickHandler implements ModalDialogProperties.Controller {
        private final Callback<Integer> mCallback;

        DialogClickHandler(Callback<Integer> onClick) {
            mCallback = onClick;
        }

        @Override
        public void onClick(PropertyModel model, int buttonType) {
            switch (buttonType) {
                case ModalDialogProperties.ButtonType.POSITIVE:
                    mCallback.onResult(DialogDismissalCause.POSITIVE_BUTTON_CLICKED);
                    dismissDialog(DialogDismissalCause.POSITIVE_BUTTON_CLICKED);
                    break;
                case ModalDialogProperties.ButtonType.NEGATIVE:
                    mCallback.onResult(DialogDismissalCause.NEGATIVE_BUTTON_CLICKED);
                    dismissDialog(DialogDismissalCause.NEGATIVE_BUTTON_CLICKED);
                    break;
                default:
                    assert false : "Unexpected button pressed in dialog: " + buttonType;
            }
        }

        @Override
        public void onDismiss(PropertyModel model, @DialogDismissalCause int dismissalCause) {
            mCallback.onResult(dismissalCause);
        }
    }

    /**
     * Constructs an instance of {@link WebFeedDialogMediator}.
     *
     * @param dialogManager {@link ModalDialogManager} for managing the dialog.
     */
    WebFeedDialogMediator(ModalDialogManager dialogManager) {
        mDialogManager = dialogManager;
    }

    /**
     * Initializes the {@link WebFeedDialogMediator}.
     *
     * @param view The {@link View} to show.
     * @param dialogContents The {@link WebFeedDialogContents} containing the dialog contents.
     */
    void initialize(View view, WebFeedDialogContents dialogContents) {
        mHostDialogModel =
                new PropertyModel.Builder(ModalDialogProperties.ALL_KEYS)
                        .with(ModalDialogProperties.CUSTOM_VIEW, view)
                        .with(ModalDialogProperties.CONTROLLER,
                                new DialogClickHandler(dialogContents.mButtonClickCallback))
                        .with(ModalDialogProperties.CONTENT_DESCRIPTION, dialogContents.mTitle)
                        .with(ModalDialogProperties.POSITIVE_BUTTON_TEXT,
                                dialogContents.mPrimaryButtonText)
                        .with(ModalDialogProperties.NEGATIVE_BUTTON_TEXT,
                                dialogContents.mSecondaryButtonText)
                        .with(ModalDialogProperties.BUTTON_STYLES,
                                dialogContents.mSecondaryButtonText != null
                                        ? ModalDialogProperties.ButtonStyles
                                                  .PRIMARY_FILLED_NEGATIVE_OUTLINE
                                        : ModalDialogProperties.ButtonStyles
                                                  .PRIMARY_OUTLINE_NEGATIVE_OUTLINE)
                        .build();
    }

    void showDialog() {
        mDialogManager.showDialog(mHostDialogModel, ModalDialogManager.ModalDialogType.APP);
    }

    void dismissDialog(int dismissalCause) {
        mDialogManager.dismissDialog(mHostDialogModel, dismissalCause);
    }
}


text:
@interface ABPerson(Additions)
-(time_t)mtime;
-(time_t)syncTime;
-(void)setMtime:(time_t)mtime;
-(void)setCtime:(time_t)ctime;
-(NSString *)stringWithDefaultLabel:(NSString *)aString;		// returns the string for the ABPerson
-(NSString *)cellName;			// "firstname lastname"
- (NSString *)printableName;		// name or company name
-(BOOL)hasLabel:(NSString *)aLabel;
-(void)addLabelsForProperty:(NSString *)propertyName toArray:(NSMutableArray *)array;
@end


text:
var Node        = require('./node');
var Declaration = require('./declaration');

// CSS node, that contain another nodes (like at-rules or rules with selectors)
class Container extends Node {
    styleMap() {
        var style = {
            beforeRule: this.before,
            beforeOpen: this.between
        };
        if ( this.childs && this.childs.length ) {
            style.beforeClose = this.after;
        } else {
            style.emptyBody = this.after;
        }
        return style;
    }

    // Stringify container childs
    stringifyContent(builder) {
        if ( !this.childs ) return;

        var i, last = this.childs.length - 1;
        while ( last > 0 ) {
            if ( this.childs[last].type != 'comment' ) break;
            last -= 1;
        }

        for ( i = 0; i < this.childs.length; i++ ) {
            this.childs[i].stringify(builder, last != i || this.semicolon);
        }
    }

    // Stringify node with start (for example, selector) and brackets block
    // with child inside
    stringifyBlock(builder, start) {
        var before = this.style('beforeRule');
        if ( before ) builder(before);
        builder(start + this.style('beforeOpen') + '{', this, 'start');

        var after;
        if ( this.childs && this.childs.length ) {
            this.stringifyContent(builder);
            after = this.style('beforeClose');
        } else {
            after = this.style('emptyBody');
        }

        if ( after ) builder(after);
        builder('}', this, 'end');
    }

    // Add child to end of list without any checks.
    // Please, use `append()` method, `push()` is mostly for parser.
    push(child) {
        child.parent = this;
        this.childs.push(child);
        return this;
    }

    // Execute `callback` on every child element. First arguments will be child
    // node, second will be index.
    //
    //   css.each( (rule, i) => {
    //       console.log(rule.type + ' at ' + i);
    //   });
    //
    // It is safe for add and remove elements to list while iterating:
    //
    //  css.each( (rule) => {
    //      css.insertBefore( rule, addPrefix(rule) );
    //      # On next iteration will be next rule, regardless of that
    //      # list size was increased
    //  });
    each(callback) {
        if ( !this.lastEach ) this.lastEach = 0;
        if ( !this.indexes )  this.indexes = { };

        this.lastEach += 1;
        var id = this.lastEach;
        this.indexes[id] = 0;

        if ( !this.childs ) return;

        var index, result;
        while ( this.indexes[id] < this.childs.length ) {
            index  = this.indexes[id];
            result = callback(this.childs[index], index);
            if ( result === false ) break;

            this.indexes[id] += 1;
        }

        delete this.indexes[id];

        if ( result === false ) return false;
    }

    // Execute callback on every child in all rules inside.
    //
    // First argument will be child node, second will be index inside parent.
    //
    //   css.eachInside( (node, i) => {
    //       console.log(node.type + ' at ' + i);
    //   });
    //
    // Also as `each` it is safe of insert/remove nodes inside iterating.
    eachInside(callback) {
        return this.each( (child, i) => {
            var result = callback(child, i);

            if ( result !== false && child.eachInside ) {
                result = child.eachInside(callback);
            }

            if ( result === false ) return result;
        });
    }

    // Execute callback on every declaration in all rules inside.
    // It will goes inside at-rules recursivelly.
    //
    // First argument will be declaration node, second will be index inside
    // parent rule.
    //
    //   css.eachDecl( (decl, i) => {
    //       console.log(decl.prop + ' in ' + decl.parent.selector + ':' + i);
    //   });
    //
    // Also as `each` it is safe of insert/remove nodes inside iterating.
    eachDecl(callback) {
        return this.eachInside( (child, i) => {
            if ( child.type == 'decl' ) {
                var result = callback(child, i);
                if ( result === false ) return result;
            }
        });
    }

    // Execute `callback` on every rule in conatiner and inside child at-rules.
    //
    // First argument will be rule node, second will be index inside parent.
    //
    //   css.eachRule( (rule, i) => {
    //       if ( parent.type == 'atrule' ) {
    //           console.log(rule.selector + ' in ' + rule.parent.name);
    //       } else {
    //           console.log(rule.selector + ' at ' + i);
    //       }
    //   });
    eachRule(callback) {
        return this.eachInside( (child, i) => {
            if ( child.type == 'rule' ) {
                var result = callback(child, i);
                if ( result === false ) return result;
            }
        });
    }

    // Execute `callback` on every at-rule in conatiner and inside at-rules.
    //
    // First argument will be at-rule node, second will be index inside parent.
    //
    //   css.eachAtRule( (atrule, parent, i) => {
    //       if ( parent.type == 'atrule' ) {
    //           console.log(atrule.name + ' in ' + atrule.parent.name);
    //       } else {
    //           console.log(atrule.name + ' at ' + i);
    //       }
    //   });
    eachAtRule(callback) {
        return this.eachInside( (child, i) => {
            if ( child.type == 'atrule' ) {
                var result = callback(child, i);
                if ( result === false ) return result;
            }
        });
    }

    // Execute callback on every block comment (only between rules
    // and declarations, not inside selectors and values) in all rules inside.
    //
    // First argument will be comment node, second will be index inside
    // parent rule.
    //
    //   css.eachComment( (comment, i) => {
    //       console.log(comment.content + ' at ' + i);
    //   });
    //
    // Also as `each` it is safe of insert/remove nodes inside iterating.
    eachComment(callback) {
        return this.eachInside( (child, i) => {
            if ( child.type == 'comment' ) {
                var result = callback(child, i);
                if ( result === false ) return result;
            }
        });
    }

    // Add child to container.
    //
    //   css.append(rule);
    //
    // You can add declaration by hash:
    //
    //   rule.append({ prop: 'color', value: 'black' });
    append(child) {
        var childs = this.normalize(child, this.last);
        for ( var i = 0; i < childs.length; i++ ) {
            this.childs.push(childs[i]);
        }
        return this;
    }

    // Add child to beginning of container
    //
    //   css.prepend(rule);
    //
    // You can add declaration by hash:
    //
    //   rule.prepend({ prop: 'color', value: 'black' });
    prepend(child) {
        var childs = this.normalize(child, this.first, 'prepend').reverse();
        for ( var i = 0; i < childs.length; i++ ) {
            this.childs.unshift(childs[i]);
        }

        for ( var id in this.indexes ) {
            this.indexes[id] = this.indexes[id] + childs.length;
        }

        return this;
    }

    // Insert new `added` child before `exist`.
    // You can set node object or node index (it will be faster) in `exist`.
    //
    //   css.insertAfter(1, rule);
    //
    // You can add declaration by hash:
    //
    //   rule.insertBefore(1, { prop: 'color', value: 'black' });
    insertBefore(exist, add) {
        exist = this.index(exist);

        var type   = exist === 0 ? 'prepend' : false;
        var childs = this.normalize(add, this.childs[exist], type).reverse();
        for ( var i = 0; i < childs.length; i++ ) {
            this.childs.splice(exist, 0, childs[i]);
        }

        var index;
        for ( var id in this.indexes ) {
            index = this.indexes[id];
            if ( exist <= index ) {
                this.indexes[id] = index + childs.length;
            }
        }

        return this;
    }

    // Insert new `added` child after `exist`.
    // You can set node object or node index (it will be faster) in `exist`.
    //
    //   css.insertAfter(1, rule);
    //
    // You can add declaration by hash:
    //
    //   rule.insertAfter(1, { prop: 'color', value: 'black' });
    insertAfter(exist, add) {
        exist = this.index(exist);

        var childs = this.normalize(add, this.childs[exist]).reverse();
        for ( var i = 0; i < childs.length; i++ ) {
            this.childs.splice(exist + 1, 0, childs[i]);
        }

        var index;
        for ( var id in this.indexes ) {
            index = this.indexes[id];
            if ( exist < index ) {
                this.indexes[id] = index + childs.length;
            }
        }

        return this;
    }

    // Remove `child` by index or node.
    //
    //   css.remove(2);
    remove(child) {
        child = this.index(child);
        this.childs.splice(child, 1);

        var index;
        for ( var id in this.indexes ) {
            index = this.indexes[id];
            if ( index >= child ) {
                this.indexes[id] = index - 1;
            }
        }

        return this;
    }

    // Return true if all childs return true in `condition`.
    // Just shorcut for `childs.every`.
    every(condition) {
        return this.childs.every(condition);
    }

    // Return true if one or more childs return true in `condition`.
    // Just shorcut for `childs.some`.
    some(condition) {
        return this.childs.some(condition);
    }

    // Return index of child
    index(child) {
        if ( typeof(child) == 'number' ) {
            return child;
        } else {
            return this.childs.indexOf(child);
        }
    }

    // Shortcut to get first child
    get first() {
        if ( !this.childs ) return undefined;
        return this.childs[0];
    }

    // Shortcut to get first child
    get last() {
        if ( !this.childs ) return undefined;
        return this.childs[this.childs.length - 1];
    }

    // Normalize child before insert. Copy before from `sample`.
    normalize(child, sample) {
        if ( !child.type && !Array.isArray(child) ) {
            child = new Declaration(child);
        }

        var childs;
        if ( child.type == 'root' ) {
            childs = child.childs;
        } else if ( Array.isArray(child) ) {
            childs = child.map( i => i.clone() );
        } else {
            if ( child.parent ) {
                child = child.clone();
            }
            childs = [child];
        }

        for ( var i = 0; i < childs.length; i++ ) {
            child = childs[i];
            child.parent = this;
            if ( typeof(child.before) == 'undefined' && sample ) {
                child.before = sample.before;
            }
        }

        return childs;
    }
}

['rules', 'decls', 'list'].forEach( (name) => {
    Object.defineProperty(Container.prototype, name, {
        get: function () {
            if ( console && console.warn ) {
                console.warn('Property ' + name + ' has been deprecated and ' +
                             'will be removed in 3.1. Use childs instead.');
            }
            return this.childs;
        }
    });
});

module.exports = Container;


text:
package org.eclipse.jgit.diff;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;

import junit.framework.TestCase;

import org.eclipse.jgit.patch.FileHeader;
import org.eclipse.jgit.patch.Patch;
import org.eclipse.jgit.util.RawParseUtils;

public class DiffFormatterReflowTest extends TestCase {
	private RawText a;

	private RawText b;

	private FileHeader file;

	private ByteArrayOutputStream out;

	private DiffFormatter fmt;

	protected void setUp() throws Exception {
		super.setUp();
		out = new ByteArrayOutputStream();
		fmt = new DiffFormatter();
	}

	public void testNegativeContextFails() throws IOException {
		init("X");
		try {
			fmt.setContext(-1);
			fail("accepted negative context");
		} catch (IllegalArgumentException e) {
			// pass
		}
	}

	public void testContext0() throws IOException {
		init("X");
		fmt.setContext(0);
		assertFormatted();
	}

	public void testContext1() throws IOException {
		init("X");
		fmt.setContext(1);
		assertFormatted();
	}

	public void testContext3() throws IOException {
		init("X");
		fmt.setContext(3);
		assertFormatted();
	}

	public void testContext5() throws IOException {
		init("X");
		fmt.setContext(5);
		assertFormatted();
	}

	public void testContext10() throws IOException {
		init("X");
		fmt.setContext(10);
		assertFormatted();
	}

	public void testContext100() throws IOException {
		init("X");
		fmt.setContext(100);
		assertFormatted();
	}

	public void testEmpty1() throws IOException {
		init("E");
		assertFormatted("E.patch");
	}

	public void testNoNewLine1() throws IOException {
		init("Y");
		assertFormatted("Y.patch");
	}

	public void testNoNewLine2() throws IOException {
		init("Z");
		assertFormatted("Z.patch");
	}

	private void init(final String name) throws IOException {
		a = new RawText(readFile(name + "_PreImage"));
		b = new RawText(readFile(name + "_PostImage"));
		file = parseTestPatchFile(name + ".patch").getFiles().get(0);
	}

	private void assertFormatted() throws IOException {
		assertFormatted(getName() + ".out");
	}

	private void assertFormatted(final String name) throws IOException {
		fmt.format(out, file, a, b);
		final String exp = RawParseUtils.decode(readFile(name));
		assertEquals(exp, RawParseUtils.decode(out.toByteArray()));
	}

	private byte[] readFile(final String patchFile) throws IOException {
		final InputStream in = getClass().getResourceAsStream(patchFile);
		if (in == null) {
			fail("No " + patchFile + " test vector");
			return null; // Never happens
		}
		try {
			final byte[] buf = new byte[1024];
			final ByteArrayOutputStream temp = new ByteArrayOutputStream();
			int n;
			while ((n = in.read(buf)) > 0)
				temp.write(buf, 0, n);
			return temp.toByteArray();
		} finally {
			in.close();
		}
	}

	private Patch parseTestPatchFile(final String patchFile) throws IOException {
		final InputStream in = getClass().getResourceAsStream(patchFile);
		if (in == null) {
			fail("No " + patchFile + " test vector");
			return null; // Never happens
		}
		try {
			final Patch p = new Patch();
			p.parse(in);
			return p;
		} finally {
			in.close();
		}
	}
}


text:
from __future__ import unicode_literals

from django.db import migrations

class Migration(migrations.Migration):

    dependencies = [
        ('dqc', '0004_auto_20160326_1504'),
    ]

    operations = [
        migrations.RenameField(
            model_name='datacolumnconstraint',
            old_name='arguments',
            new_name='argument',
        ),
        migrations.RemoveField(
            model_name='datacolumnconstraint',
            name='validation_schema',
        ),
    ]


text:
namespace TeamleaderDotNet.Common.JsonConvertors
{
    public enum NumberSeriesDirections
    {
        Up,
        Down
    }

    public class NumberSeries
    {
        private readonly NumberSeriesDirections _direction;
        private int _nextNumber;

        public NumberSeries(NumberSeriesDirections direction, int start = 0)
        {
            _direction = direction;
            _nextNumber = start;
        }

        public int Next()
        {
            _nextNumber = _direction == NumberSeriesDirections.Up
                ? _nextNumber++
                : _nextNumber--;

            return _nextNumber;
        }
    }
}


text:
namespace EMS.Core.Entities
{
    using System;
    using System.Collections.Generic;

    public partial class Report
    {
        public Report()
        {
            this.MeterReadings = new HashSet<MeterReading>();
        }

        public int Id { get; set; }
        public string Name { get; set; }
        public DateTime CreatedDate { get; set; }
        public DateTime AlteredDate { get; set; }
        public string IP { get; set; }

        public System.DateTime ReportDate { get; set; }
        public int SupplierId { get; set; }

        public virtual ICollection<MeterReading> MeterReadings { get; set; }
        public virtual Supplier Supplier { get; set; }
    }
}


text:
<?xml version="1.0" encoding="utf-8"?>
<resources>

    <!-- From: file:/Users/khankuan/Desktop/yotacast/android/YotaCast/yotaphone_titanium_sdk/res/values-zh-rCN/strings.xml -->
    <eat-comment />

    <string name="application_is_updated_on_bs" comment="Please split the string in more lines if it is longer then 35 symbols">应用程序已在 always-on 显示屏\n上进行了更新</string>
    <string name="flip_popup_default_description">应用程序正在彩色显示屏\n上运行</string>
    <string name="flip_popup_default_title">翻转手机</string>
    <string name="loading_data">正在加载数据...</string>

</resources>


text:
<?xml version="1.0"?>

<document xmlns="http://maven.apache.org/XDOC/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd">
  <properties>
    <title>Multiple applications in one MBeanServer</title>
  </properties>

  		If you want to run multiple Gaderian applications which
  		use JMX in a single JVM or application server, then there is
  		a chance of getting naming collisions.

  		By default Gaderian prepends "gaderian:" as domain name to
  		the names of all MBeans. For example the service
  		"test.management.Calculator" gets registered using the
  		ObjectName "gaderian:module=test.management,type=service,id=Calculator".

  		If multiple applications export the same service you
  		should must choose unique domain names for each application.
  		The domain name is configured as ApplicationSymbol:

		<source><![CDATA[
<contribution configuration-id="gaderian.ApplicationDefaults">
  <default symbol="management.naming.domain" value="myDomain" />
</contribution>]]></source>

</document>