text:
package org.daisy.dotify.formatter.test;

import org.daisy.dotify.api.engine.FormatterEngine;
import org.daisy.dotify.api.engine.FormatterEngineMaker;
import org.daisy.dotify.api.engine.LayoutEngineException;
import org.daisy.dotify.api.translator.TranslatorType;
import org.daisy.dotify.api.writer.MediaTypes;
import org.daisy.dotify.api.writer.PagedMediaWriterConfigurationException;
import org.daisy.dotify.api.writer.PagedMediaWriterFactory;
import org.daisy.dotify.api.writer.PagedMediaWriterFactoryMaker;
import org.junit.Test;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.logging.Logger;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;

/**
 * TODO: Write java doc.
 */
@SuppressWarnings("javadoc")
public class LayoutEngineTest extends AbstractFormatterEngineTest {
    private static final Logger logger = Logger.getLogger(LayoutEngineTest.class.getCanonicalName());

    @Test
    public void testLayoutEngine() throws
            LayoutEngineException,
            IOException,
            PagedMediaWriterConfigurationException {

        PagedMediaWriterFactory f = PagedMediaWriterFactoryMaker.newInstance().getFactory(MediaTypes.TEXT_MEDIA_TYPE);
        FormatterEngine engine = FormatterEngineMaker.newInstance().newFormatterEngine("en",
                TranslatorType.BYPASS.toString(),
                f.newPagedMediaWriter());
        File res = File.createTempFile("TestResult", ".tmp");
        res.deleteOnExit();

        engine.convert(
            this.getClass().getResourceAsStream("resource-files/obfl-input.obfl"), new FileOutputStream(res)
        );

        try {
            int ret = compareBinary(
                this.getClass().getResourceAsStream("resource-files/obfl-expected.txt"), new FileInputStream(res)
            );
            assertEquals("Binary compare is equal", -1, ret);
        } catch (IOException e) {
            logger.throwing(AbstractFormatterEngineTest.class.getName(), "testLayoutEngine", e);
            fail();
        } finally {
            if (!res.delete()) {
                logger.severe("Delete failed.");
            }
        }
    }

    @Test
    public void testLayoutEngingeDLS() throws
            LayoutEngineException,
            IOException,
            PagedMediaWriterConfigurationException {
        testPEF(
            "resource-files/obfl-input-dls.obfl",
            "resource-files/obfl-dls-expected.pef",
            false
        );
    }

    @Test
    public void testLayoutEngingeBorder() throws
            LayoutEngineException,
            IOException,
            PagedMediaWriterConfigurationException {
        testPEF(
            "resource-files/obfl-input-border.obfl",
            "resource-files/obfl-border-expected.pef",
            false
        );
    }

    @Test
    public void testLayoutEngingeToc() throws
            LayoutEngineException,
            IOException,
            PagedMediaWriterConfigurationException {
        testPEF(
            "resource-files/obfl-input-toc.obfl",
            "resource-files/obfl-toc-expected.pef",
            false
        );
    }

    @Test
    public void testLayoutEngingeContentItems() throws
            LayoutEngineException,
            IOException,
            PagedMediaWriterConfigurationException {
        testPEF(
            "resource-files/obfl-input-content-items.obfl",
            "resource-files/obfl-content-items-expected.pef",
            false
        );
    }

    @Test
    public void testLayoutEngingeContentItemsFallback() throws
            LayoutEngineException,
            IOException,
            PagedMediaWriterConfigurationException {
        testPEF(
            "resource-files/obfl-input-content-items-fallback.obfl",
            "resource-files/obfl-content-items-fallback-expected.pef",
            false
        );
    }

    @Test
    public void testLayoutEngingeContentItemsFallback2() throws
            LayoutEngineException,
            IOException,
            PagedMediaWriterConfigurationException {
        testPEF(
            "resource-files/obfl-input-content-items-fallback2.obfl",
            "resource-files/obfl-content-items-fallback2-expected.pef",
            false
        );
    }

    @Test
    public void testLayoutEngingeContentItemsFallback3() throws
            LayoutEngineException,
            IOException,
            PagedMediaWriterConfigurationException {
        testPEF(
            "resource-files/obfl-input-content-items-fallback3.obfl",
            "resource-files/obfl-content-items-fallback3-expected.pef",
            false
        );
    }

    @Test (expected = RuntimeException.class)
    public void testLayoutEngineContentItemsNoFallback() throws
            LayoutEngineException,
            IOException,
            PagedMediaWriterConfigurationException {
        testPEF(
            "resource-files/obfl-input-content-items-no-fallback.obfl",
            null,
            false
        );
    }

    public int compareBinary(InputStream f1, InputStream f2) throws IOException {
        InputStream bf1 = new BufferedInputStream(f1);
        InputStream bf2 = new BufferedInputStream(f2);
        int pos = 0;
        try {
            int b1;
            int b2;
            while ((b1 = bf1.read()) != -1 & b1 == (b2 = bf2.read())) {
                pos++;
                // continue
            }
            if (b1 != -1 || b2 != -1) {
                return pos;
            }
            return -1;
        } finally {
            bf1.close();
            bf2.close();
        }
    }
}


text:
'use strict'

global.chai = require('chai')
global.should = chai.should()

redpajama_set_name: RedPajamaGithub


text:
/**
 * @author Alexey A. Ivanov
 * @version $Revision$
 */
package javax.swing.text;

public class BadLocationException extends Exception {
    private int offset;

    public BadLocationException(final String description, final int offset) {
        super(description);
        this.offset = offset;
    }

    public int offsetRequested() {
        return offset;
    }
}


text:
namespace llvm {
namespace xray {

/// XRay traces all have a header providing some top-matter information useful
/// to help tools determine how to interpret the information available in the
/// trace.
struct XRayFileHeader {
  /// Version of the XRay implementation that produced this file.
  uint16_t Version = 0;

  /// A numeric identifier for the type of file this is. Best used in
  /// combination with Version.
  uint16_t Type = 0;

  /// Whether the CPU that produced the timestamp counters (TSC) move at a
  /// constant rate.
  bool ConstantTSC;

  /// Whether the CPU that produced the timestamp counters (TSC) do not stop.
  bool NonstopTSC;

  /// The number of cycles per second for the CPU that produced the timestamp
  /// counter (TSC) values. Useful for estimating the amount of time that
  /// elapsed between two TSCs on some platforms.
  uint64_t CycleFrequency = 0;
};

/// Determines the supported types of records that could be seen in XRay traces.
/// This may or may not correspond to actual record types in the raw trace (as
/// the loader implementation may synthesize this information in the process of
/// of loading).
enum class RecordTypes { ENTER, EXIT };

struct XRayRecord {
  /// The type of record.
  uint16_t RecordType;

  /// The CPU where the thread is running. We assume number of CPUs <= 256.
  uint8_t CPU;

  /// Identifies the type of record.
  RecordTypes Type;

  /// The function ID for the record.
  int32_t FuncId;

  /// Get the full 8 bytes of the TSC when we get the log record.
  uint64_t TSC;

  /// The thread ID for the currently running thread.
  uint32_t TId;
};

} // namespace xray
} // namespace llvm

#endif // LLVM_XRAY_XRAY_RECORD_H