<commit_before><?php

require_once ("../spyc.php");

class DumpTest extends PHPUnit_Framework_TestCase {

    private $files_to_test = array();

    public function setUp() {
      $this->files_to_test = array ('../spyc.yaml', 'failing1.yaml', 'indent_1.yaml', 'quotes.yaml');
    }

    public function testDump() {
      foreach ($this->files_to_test as $file) {
        $yaml = spyc_load(file_get_contents($file));
        $dump = Spyc::YAMLDump ($yaml);
        $yaml_after_dump = Spyc::YAMLLoad ($dump);
        $this->assertEquals ($yaml, $yaml_after_dump);
      }
    }

    public function testDumpWithQuotes() {
      $Spyc = new Spyc();
      $Spyc->setting_dump_force_quotes = true;
      foreach ($this->files_to_test as $file) {
        $yaml = $Spyc->load(file_get_contents($file));
        $dump = $Spyc->dump ($yaml);
        $yaml_after_dump = Spyc::YAMLLoad ($dump);
        $this->assertEquals ($yaml, $yaml_after_dump);
      }
    }

    public function testDumpArrays() {
      $dump = Spyc::YAMLDump(array ('item1', 'item2', 'item3'));
      $awaiting = "---\n- item1\n- item2\n- item3\n";
      $this->assertEquals ($awaiting, $dump);
    }
    
    public function testNull() {
        $dump = Spyc::YAMLDump(array('a' => 1, 'b' => null, 'c' => 3));
        $awaiting = "---\na: 1\nb: null\nc: 3\n";
        $this->assertEquals ($awaiting, $dump);
    }
    
    public function testDumpingMixedArrays() {
        $array = array();<commit_msg>Adding test for issue #41.<commit_after><?php

require_once ("../spyc.php");

class DumpTest extends PHPUnit_Framework_TestCase {

    private $files_to_test = array();

    public function setUp() {
      $this->files_to_test = array ('../spyc.yaml', 'failing1.yaml', 'indent_1.yaml', 'quotes.yaml');
    }

    public function testDump() {
      foreach ($this->files_to_test as $file) {
        $yaml = spyc_load(file_get_contents($file));
        $dump = Spyc::YAMLDump ($yaml);
        $yaml_after_dump = Spyc::YAMLLoad ($dump);
        $this->assertEquals ($yaml, $yaml_after_dump);
      }
    }

    public function testDumpWithQuotes() {
      $Spyc = new Spyc();
      $Spyc->setting_dump_force_quotes = true;
      foreach ($this->files_to_test as $file) {
        $yaml = $Spyc->load(file_get_contents($file));
        $dump = $Spyc->dump ($yaml);
        $yaml_after_dump = Spyc::YAMLLoad ($dump);
        $this->assertEquals ($yaml, $yaml_after_dump);
      }
    }

    public function testDumpArrays() {
      $dump = Spyc::YAMLDump(array ('item1', 'item2', 'item3'));
      $awaiting = "---\n- item1\n- item2\n- item3\n";
      $this->assertEquals ($awaiting, $dump);
    }
    
    public function testNull() {
        $dump = Spyc::YAMLDump(array('a' => 1, 'b' => null, 'c' => 3));
        $awaiting = "---\na: 1\nb: null\nc: 3\n";
        $this->assertEquals ($awaiting, $dump);
    }
    
    public function testNext() {
        $array = array("aaa", "bbb", "ccc");
        #set arrays internal pointer to next element
        next($array);
        $dump = Spyc::YAMLDump($array);        
        $awaiting = "---\n- aaa\n- bbb\n- ccc\n";
        $this->assertEquals ($awaiting, $dump);        
    }
    
    public function testDumpingMixedArrays() {
        $array = array();
{'fraction_non_alphanumeric': 0.17436524931171613, 'fraction_numerical': 0.007953502600183543, 'mean_word_length': 2.609271523178808, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 30, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7276525', 'n_tokens_mistral': 1142, 'n_tokens_neox': 1138, 'n_words': 226}