<commit_before>/**
*    Copyright (C) 2008 10gen Inc.
*  
*    This program is free software: you can redistribute it and/or  modify
*    it under the terms of the GNU Affero General Public License, version 3,
*    as published by the Free Software Foundation.
*  
*    This program is distributed in the hope that it will be useful,
*    but WITHOUT ANY WARRANTY; without even the implied warranty of
*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*    GNU Affero General Public License for more details.
*  
*    You should have received a copy of the GNU Affero General Public License
*    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

package ed.lang.ruby;

import org.testng.annotations.*;
import static org.testng.Assert.*;

@Test(groups = {"ruby", "ruby.erbsource"})
public class RubyErbSourceTest extends ErbSourceRunner {

    @BeforeMethod(groups={"ruby", "ruby.erbsource"})
    public void setUp() {
	super.setUp();
	runJS("add_seven = function(i) { return i + 7; };" +
	      "two_args = function(a, b) { return a + b; };" +
	      "data = {};" +
	      "data.count = 1;" +
	      "data.subobj = {};" +
	      "data.subobj.subvar = 99;" +
	      "data.subobj.add_seven = add_seven;" +
	      "data.add_seven = add_seven;" +
	      "array = [100, \"test string\", null, add_seven];");
    }

    public void testSimple() {
	assertRubyEquals("<%= $data.count %>", "1");
    }

    // FIXME this works for real, but in this test framework $scope.print is
    // not working correctly.
//     public void testJSPrintWorksInline() {
// 	assertRubyEquals("foo <% $scope.print('bar') %> bletch", "foo bar bletch");
//     }

    public void testJSPrintRestoredAfterRun() {
	runRuby("foo <% $scope.print('bar') %> bletch");
	assertJSEquals("print('hello, world!');", "hello, world!");
    }
}<commit_msg>Uncommented $scope.print test that works now.<commit_after>/**
*    Copyright (C) 2008 10gen Inc.
*  
*    This program is free software: you can redistribute it and/or  modify
*    it under the terms of the GNU Affero General Public License, version 3,
*    as published by the Free Software Foundation.
*  
*    This program is distributed in the hope that it will be useful,
*    but WITHOUT ANY WARRANTY; without even the implied warranty of
*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*    GNU Affero General Public License for more details.
*  
*    You should have received a copy of the GNU Affero General Public License
*    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

package ed.lang.ruby;

import org.testng.annotations.*;
import static org.testng.Assert.*;

@Test(groups = {"ruby", "ruby.erbsource"})
public class RubyErbSourceTest extends ErbSourceRunner {

    @BeforeMethod(groups={"ruby", "ruby.erbsource"})
    public void setUp() {
	super.setUp();
	runJS("add_seven = function(i) { return i + 7; };" +
	      "two_args = function(a, b) { return a + b; };" +
	      "data = {};" +
	      "data.count = 1;" +
	      "data.subobj = {};" +
	      "data.subobj.subvar = 99;" +
	      "data.subobj.add_seven = add_seven;" +
	      "data.add_seven = add_seven;" +
	      "array = [100, \"test string\", null, add_seven];");
    }

    public void testSimple() {
	assertRubyEquals("<%= $data.count %>", "1");
    }

    public void testJSPrintWorksInline() {
	assertRubyEquals("foo <% $scope.print('bar') %> bletch", "foo bar bletch");
    }

    public void testJSPrintRestoredAfterRun() {
	runRuby("foo <% $scope.print('bar') %> bletch");
	assertJSEquals("print('hello, world!');", "hello, world!");
    }
}
{'fraction_non_alphanumeric': 0.14195148842337377, 'fraction_numerical': 0.008269018743109152, 'mean_word_length': 3.219767441860465, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2002509', 'n_tokens_mistral': 1205, 'n_tokens_neox': 1132, 'n_words': 360}