text:
require 'abstract_unit'

silence_warnings do
  Post = Struct.new(:title, :author_name, :body, :secret, :written_on, :cost)
  Post.class_eval do
    alias_method :title_before_type_cast, :title unless respond_to?(:title_before_type_cast)
    alias_method :body_before_type_cast, :body unless respond_to?(:body_before_type_cast)
    alias_method :author_name_before_type_cast, :author_name unless respond_to?(:author_name_before_type_cast)
    alias_method :secret?, :secret

    def new_record=(boolean)
      @new_record = boolean
    end

    def new_record?
      @new_record
    end

    attr_accessor :author
    def author_attributes=(attributes); end

    attr_accessor :comments
    def comments_attributes=(attributes); end
  end

  class Comment
    attr_reader :id
    attr_reader :post_id
    def initialize(id = nil, post_id = nil); @id, @post_id = id, post_id end
    def save; @id = 1; @post_id = 1 end
    def new_record?; @id.nil? end
    def to_param; @id; end
    def name
      @id.nil? ? "new #{self.class.name.downcase}" : "#{self.class.name.downcase} ##{@id}"
    end
  end

  class Author < Comment
    attr_accessor :post
    def post_attributes=(attributes); end
  end
end

class FormHelperTest < ActionView::TestCase
  tests ActionView::Helpers::FormHelper

  def setup
    @post = Post.new
    @comment = Comment.new
    def @post.errors()
      Class.new{
        def on(field); "can't be empty" if field == "author_name"; end
        def empty?() false end
        def count() 1 end
        def full_messages() [ "Author name can't be empty" ] end
      }.new
    end
    def @post.id; 123; end
    def @post.id_before_type_cast; 123; end
    def @post.to_param; '123'; end

    @post.title       = "Hello World"
    @post.author_name = ""
    @post.body        = "Back to the hill and over it again!"
    @post.secret      = 1
    @post.written_on  = Date.new(2004, 6, 15)

    @controller = Class.new do
      attr_reader :url_for_options
      def url_for(options)
        @url_for_options = options
        "http://www.example.com"
      end
    end
    @controller = @controller.new
  end

  def test_label
    assert_dom_equal('Title', label("post", "title"))
    assert_dom_equal('The title goes here', label("post", "title", "The title goes here"))
    assert_dom_equal(
      'Title',
      label("post", "title", nil, :class => 'title_label')
    )
    assert_dom_equal('Secret?', label("post", "secret?"))
  end

  def test_label_with_symbols
    assert_dom_equal('Title', label(:post, :title))
    assert_dom_equal('Secret?', label(:post, :secret?))
  end

  def test_label_with_for_attribute_as_symbol
    assert_dom_equal('Title', label(:post, :title, nil, :for => "my_for"))
  end

  def test_label_with_for_attribute_as_string
    assert_dom_equal('Title', label(:post, :title, nil, "for" => "my_for"))
  end

  def test_text_field
    assert_dom_equal(
      '<input id="post_title" name="post[title]" size="30" type="text" value="Hello World" />', text_field("post", "title")
    )
    assert_dom_equal(
      '<input id="post_title" name="post[title]" size="30" type="password" value="Hello World" />', password_field("post", "title")
    )
    assert_dom_equal(
      '<input id="person_name" name="person[name]" size="30" type="password" />', password_field("person", "name")
    )
  end

  def test_text_field_with_escapes
    @post.title = "Hello World"
    assert_dom_equal(
      '<input id="post_title" name="post[title]" size="30" type="text" value="<b>Hello World</b>" />', text_field("post", "title")
    )
  end

  def test_text_field_with_html_entities
    @post.title = "The HTML Entity for & is &"
    assert_dom_equal(
      '<input id="post_title" name="post[title]" size="30" type="text" value="The HTML Entity for & is &amp;" />',
      text_field("post", "title")
    )
  end

  def test_text_field_with_options
    expected = '<input id="post_title" name="post[title]" size="35" type="text" value="Hello World" />'
    assert_dom_equal expected, text_field("post", "title", "size" => 35)
    assert_dom_equal expected, text_field("post", "title", :size => 35)
  end

  def test_text_field_assuming_size
    expected = '<input id="post_title" maxlength="35" name="post[title]" size="35" type="text" value="Hello World" />'
    assert_dom_equal expected, text_field("post", "title", "maxlength" => 35)
    assert_dom_equal expected, text_field("post", "title", :maxlength => 35)
  end

  def test_text_field_removing_size
    expected = '<input id="post_title" maxlength="35" name="post[title]" type="text" value="Hello World" />'
    assert_dom_equal expected, text_field("post", "title", "maxlength" => 35, "size" => nil)
    assert_dom_equal expected, text_field("post", "title", :maxlength => 35, :size => nil)
  end

  def test_text_field_doesnt_change_param_values
    object_name = 'post[]'
    expected = '<input id="post_123_title" name="post[123][title]" size="30" type="text" value="Hello World" />'
    assert_equal expected, text_field(object_name, "title")
    assert_equal object_name, "post[]"
  end

  def test_hidden_field
    assert_dom_equal '<input id="post_title" name="post[title]" type="hidden" value="Hello World" />',
      hidden_field("post", "title")
      assert_dom_equal '<input id="post_secret" name="post[secret]" type="hidden" value="1" />',
        hidden_field("post", "secret?")
  end

  def test_hidden_field_with_escapes
    @post.title = "Hello World"
    assert_dom_equal '<input id="post_title" name="post[title]" type="hidden" value="<b>Hello World</b>" />',
      hidden_field("post", "title")
  end

  def test_text_field_with_options
    assert_dom_equal '<input id="post_title" name="post[title]" type="hidden" value="Something Else" />',
      hidden_field("post", "title", :value => "Something Else")
  end

  def test_check_box
    assert_dom_equal(
      '<input name="post[secret]" type="hidden" value="0" /><input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="1" />',
      check_box("post", "secret")
    )
    @post.secret = 0
    assert_dom_equal(
      '<input name="post[secret]" type="hidden" value="0" /><input id="post_secret" name="post[secret]" type="checkbox" value="1" />',
      check_box("post", "secret")
    )
    assert_dom_equal(
      '<input name="post[secret]" type="hidden" value="0" /><input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="1" />',
      check_box("post", "secret" ,{"checked"=>"checked"})
    )
    @post.secret = true
    assert_dom_equal(
      '<input name="post[secret]" type="hidden" value="0" /><input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="1" />',
      check_box("post", "secret")
    )
    assert_dom_equal(
      '<input name="post[secret]" type="hidden" value="0" /><input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="1" />',
      check_box("post", "secret?")
    )

    @post.secret = ['0']
    assert_dom_equal(
      '<input name="post[secret]" type="hidden" value="0" /><input id="post_secret" name="post[secret]" type="checkbox" value="1" />',
      check_box("post", "secret")
    )
    @post.secret = ['1']
    assert_dom_equal(
      '<input name="post[secret]" type="hidden" value="0" /><input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="1" />',
      check_box("post", "secret")
    )
  end

  def test_check_box_with_explicit_checked_and_unchecked_values
    @post.secret = "on"
    assert_dom_equal(
      '<input name="post[secret]" type="hidden" value="off" /><input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="on" />',
      check_box("post", "secret", {}, "on", "off")
    )
  end

  def test_checkbox_disabled_still_submits_checked_value
    assert_dom_equal(
      '<input name="post[secret]" type="hidden" value="1" /><input checked="checked" disabled="disabled" id="post_secret" name="post[secret]" type="checkbox" value="1" />',
      check_box("post", "secret", { :disabled => :true })
    )
  end

  def test_radio_button
    assert_dom_equal('<input checked="checked" id="post_title_hello_world" name="post[title]" type="radio" value="Hello World" />',
      radio_button("post", "title", "Hello World")
    )
    assert_dom_equal('<input id="post_title_goodbye_world" name="post[title]" type="radio" value="Goodbye World" />',
      radio_button("post", "title", "Goodbye World")
    )
    assert_dom_equal('<input id="item_subobject_title_inside_world" name="item[subobject][title]" type="radio" value="inside world"/>',
      radio_button("item[subobject]", "title", "inside world")
    )
  end

  def test_radio_button_is_checked_with_integers
    assert_dom_equal('<input checked="checked" id="post_secret_1" name="post[secret]" type="radio" value="1" />',
      radio_button("post", "secret", "1")
   )
  end

  def test_radio_button_respects_passed_in_id
     assert_dom_equal('<input checked="checked" id="foo" name="post[secret]" type="radio" value="1" />',
       radio_button("post", "secret", "1", :id=>"foo")
    )
  end

  def test_text_area
    assert_dom_equal(
      '<textarea cols="40" id="post_body" name="post[body]" rows="20">Back to the hill and over it again!</textarea>',
      text_area("post", "body")
    )
  end

  def test_text_area_with_escapes
    @post.body        = "Back to the hill and over it again!"
    assert_dom_equal(
      '<textarea cols="40" id="post_body" name="post[body]" rows="20">Back to <i>the</i> hill and over it again!</textarea>',
      text_area("post", "body")
    )
  end

  def test_text_area_with_alternate_value
    assert_dom_equal(
      '<textarea cols="40" id="post_body" name="post[body]" rows="20">Testing alternate values.</textarea>',
      text_area("post", "body", :value => 'Testing alternate values.')
    )
  end

  def test_text_area_with_html_entities
    @post.body        = "The HTML Entity for & is &"
    assert_dom_equal(
      '<textarea cols="40" id="post_body" name="post[body]" rows="20">The HTML Entity for & is &amp;</textarea>',
      text_area("post", "body")
    )
  end

  def test_text_area_with_size_option
    assert_dom_equal(
      '<textarea cols="183" id="post_body" name="post[body]" rows="820">Back to the hill and over it again!</textarea>',
      text_area("post", "body", :size => "183x820")
    )
  end

  def test_explicit_name
    assert_dom_equal(
      '<input id="post_title" name="dont guess" size="30" type="text" value="Hello World" />', text_field("post", "title", "name" => "dont guess")
    )
    assert_dom_equal(
      '<textarea cols="40" id="post_body" name="really!" rows="20">Back to the hill and over it again!</textarea>',
      text_area("post", "body", "name" => "really!")
    )
    assert_dom_equal(
      '<input name="i mean it" type="hidden" value="0" /><input checked="checked" id="post_secret" name="i mean it" type="checkbox" value="1" />',
      check_box("post", "secret", "name" => "i mean it")
    )
    assert_dom_equal text_field("post", "title", "name" => "dont guess"),
                 text_field("post", "title", :name => "dont guess")
    assert_dom_equal text_area("post", "body", "name" => "really!"),
                 text_area("post", "body", :name => "really!")
    assert_dom_equal check_box("post", "secret", "name" => "i mean it"),
                 check_box("post", "secret", :name => "i mean it")
  end

  def test_explicit_id
    assert_dom_equal(
      '<input id="dont guess" name="post[title]" size="30" type="text" value="Hello World" />', text_field("post", "title", "id" => "dont guess")
    )
    assert_dom_equal(
      '<textarea cols="40" id="really!" name="post[body]" rows="20">Back to the hill and over it again!</textarea>',
      text_area("post", "body", "id" => "really!")
    )
    assert_dom_equal(
      '<input name="post[secret]" type="hidden" value="0" /><input checked="checked" id="i mean it" name="post[secret]" type="checkbox" value="1" />',
      check_box("post", "secret", "id" => "i mean it")
    )
    assert_dom_equal text_field("post", "title", "id" => "dont guess"),
                 text_field("post", "title", :id => "dont guess")
    assert_dom_equal text_area("post", "body", "id" => "really!"),
                 text_area("post", "body", :id => "really!")
    assert_dom_equal check_box("post", "secret", "id" => "i mean it"),
                 check_box("post", "secret", :id => "i mean it")
  end

  def test_auto_index
    pid = @post.id
    assert_dom_equal(
      "Title",
      label("post[]", "title")
    )
    assert_dom_equal(
      "<input id=\"post_#{pid}_title\" name=\"post[#{pid}][title]\" size=\"30\" type=\"text\" value=\"Hello World\" />", text_field("post[]","title")
    )
    assert_dom_equal(
      "<textarea cols=\"40\" id=\"post_#{pid}_body\" name=\"post[#{pid}][body]\" rows=\"20\">Back to the hill and over it again!</textarea>",
      text_area("post[]", "body")
    )
    assert_dom_equal(
      "<input name=\"post[#{pid}][secret]\" type=\"hidden\" value=\"0\" /><input checked=\"checked\" id=\"post_#{pid}_secret\" name=\"post[#{pid}][secret]\" type=\"checkbox\" value=\"1\" />",
      check_box("post[]", "secret")
    )
   assert_dom_equal(
"<input checked=\"checked\" id=\"post_#{pid}_title_hello_world\" name=\"post[#{pid}][title]\" type=\"radio\" value=\"Hello World\" />",
      radio_button("post[]", "title", "Hello World")
    )
    assert_dom_equal("<input id=\"post_#{pid}_title_goodbye_world\" name=\"post[#{pid}][title]\" type=\"radio\" value=\"Goodbye World\" />",
      radio_button("post[]", "title", "Goodbye World")
    )
  end

  def test_form_for
    form_for(:post, @post, :html => { :id => 'create-post' }) do |f|
      concat f.label(:title)
      concat f.text_field(:title)
      concat f.text_area(:body)
      concat f.check_box(:secret)
      concat f.submit('Create post')
    end

    expected =
      "<form action='http://www.example.com' id='create-post' method='post'>" +
      "Title" +
      "<input name='post[title]' size='30' type='text' id='post_title' value='Hello World' />" +
      "<textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" +
      "<input name='post[secret]' type='hidden' value='0' />" +
      "<input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />" +
      "<input name='commit' id='post_submit' type='submit' value='Create post' />" +
      "</form>"

    assert_dom_equal expected, output_buffer
  end

  def test_form_for_with_method
    form_for(:post, @post, :html => { :id => 'create-post', :method => :put }) do |f|
      concat f.text_field(:title)
      concat f.text_area(:body)
      concat f.check_box(:secret)
    end

    expected =
      "<form action='http://www.example.com' id='create-post' method='post'>" +
      "
<input name='_method' type='hidden' value='put' />
" +
      "<input name='post[title]' size='30' type='text' id='post_title' value='Hello World' />" +
      "<textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" +
      "<input name='post[secret]' type='hidden' value='0' />" +
      "<input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />" +
      "</form>"

    assert_dom_equal expected, output_buffer
  end

  def test_form_for_without_object
    form_for(:post, :html => { :id => 'create-post' }) do |f|
      concat f.text_field(:title)
      concat f.text_area(:body)
      concat f.check_box(:secret)
    end

    expected =
      "<form action='http://www.example.com' id='create-post' method='post'>" +
      "<input name='post[title]' size='30' type='text' id='post_title' value='Hello World' />" +
      "<textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" +
      "<input name='post[secret]' type='hidden' value='0' />" +
      "<input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />" +
      "</form>"

    assert_dom_equal expected, output_buffer
  end

  def test_form_for_with_index
    form_for("post[]", @post) do |f|
      concat f.label(:title)
      concat f.text_field(:title)
      concat f.text_area(:body)
      concat f.check_box(:secret)
    end

    expected =
      "<form action='http://www.example.com' method='post'>" +
      "Title" +
      "<input name='post[123][title]' size='30' type='text' id='post_123_title' value='Hello World' />" +
      "<textarea name='post[123][body]' id='post_123_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" +
      "<input name='post[123][secret]' type='hidden' value='0' />" +
      "<input name='post[123][secret]' checked='checked' type='checkbox' id='post_123_secret' value='1' />" +
      "</form>"

    assert_dom_equal expected, output_buffer
  end

  def test_form_for_with_nil_index_option_override
    form_for("post[]", @post, :index => nil) do |f|
      concat f.text_field(:title)
      concat f.text_area(:body)
      concat f.check_box(:secret)
    end

    expected =
      "<form action='http://www.example.com' method='post'>" +
      "<input name='post[][title]' size='30' type='text' id='post__title' value='Hello World' />" +
      "<textarea name='post[][body]' id='post__body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" +
      "<input name='post[][secret]' type='hidden' value='0' />" +
      "<input name='post[][secret]' checked='checked' type='checkbox' id='post__secret' value='1' />" +
      "</form>"

    assert_dom_equal expected, output_buffer
  end

  def test_nested_fields_for
    form_for(:post, @post) do |f|
      f.fields_for(:comment, @post) do |c|
        concat c.text_field(:title)
      end
    end

    expected = "<form action='http://www.example.com' method='post'>" +
               "<input name='post[comment][title]' size='30' type='text' id='post_comment_title' value='Hello World' />" +
               "</form>"

    assert_dom_equal expected, output_buffer
  end

  def test_nested_fields_for_with_nested_collections
    form_for('post[]', @post) do |f|
      concat f.text_field(:title)
      f.fields_for('comment[]', @comment) do |c|
        concat c.text_field(:name)
      end
    end

    expected = "<form action='http://www.example.com' method='post'>" +
               "<input name='post[123][title]' size='30' type='text' id='post_123_title' value='Hello World' />" +
               "<input name='post[123][comment][][name]' size='30' type='text' id='post_123_comment__name' value='new comment' />" +
               "</form>"

    assert_dom_equal expected, output_buffer
  end

  def test_nested_fields_for_with_index_and_parent_fields
    form_for('post', @post, :index => 1) do |c|
      concat c.text_field(:title)
      c.fields_for('comment', @comment, :index => 1) do |r|
        concat r.text_field(:name)
      end
    end

    expected = "<form action='http://www.example.com' method='post'>" +
               "<input name='post[1][title]' size='30' type='text' id='post_1_title' value='Hello World' />" +
               "<input name='post[1][comment][1][name]' size='30' type='text' id='post_1_comment_1_name' value='new comment' />" +
               "</form>"

    assert_dom_equal expected, output_buffer
  end

  def test_form_for_with_index_and_nested_fields_for
    form_for(:post, @post, :index => 1) do |f|
      f.fields_for(:comment, @post) do |c|
        concat c.text_field(:title)
      end
    end

    expected = "<form action='http://www.example.com' method='post'>" +
               "<input name='post[1][comment][title]' size='30' type='text' id='post_1_comment_title' value='Hello World' />" +
               "</form>"

    assert_dom_equal expected, output_buffer
  end

  def test_nested_fields_for_with_index_on_both
    form_for(:post, @post, :index => 1) do |f|
      f.fields_for(:comment, @post, :index => 5) do |c|
        concat c.text_field(:title)
      end
    end

    expected = "<form action='http://www.example.com' method='post'>" +
               "<input name='post[1][comment][5][title]' size='30' type='text' id='post_1_comment_5_title' value='Hello World' />" +
               "</form>"

    assert_dom_equal expected, output_buffer
  end

  def test_nested_fields_for_with_auto_index
    form_for("post[]", @post) do |f|
      f.fields_for(:comment, @post) do |c|
        concat c.text_field(:title)
      end
    end

    expected = "<form action='http://www.example.com' method='post'>" +
               "<input name='post[123][comment][title]' size='30' type='text' id='post_123_comment_title' value='Hello World' />" +
               "</form>"

    assert_dom_equal expected, output_buffer
  end

  def test_nested_fields_for_with_auto_index_on_both
    form_for("post[]", @post) do |f|
      f.fields_for("comment[]", @post) do |c|
        concat c.text_field(:title)
      end
    end

    expected = "<form action='http://www.example.com' method='post'>" +
               "<input name='post[123][comment][123][title]' size='30' type='text' id='post_123_comment_123_title' value='Hello World' />" +
               "</form>"

    assert_dom_equal expected, output_buffer
  end

  def test_nested_fields_for_with_index_and_auto_index
    form_for("post[]", @post) do |f|
      f.fields_for(:comment, @post, :index => 5) do |c|
        concat c.text_field(:title)
      end
    end

    form_for(:post, @post, :index => 1) do |f|
      f.fields_for("comment[]", @post) do |c|
        concat c.text_field(:title)
      end
    end

    expected = "<form action='http://www.example.com' method='post'>" +
               "<input name='post[123][comment][5][title]' size='30' type='text' id='post_123_comment_5_title' value='Hello World' />" +
               "</form>" +
               "<form action='http://www.example.com' method='post'>" +
               "<input name='post[1][comment][123][title]' size='30' type='text' id='post_1_comment_123_title' value='Hello World' />" +
               "</form>"

    assert_dom_equal expected, output_buffer
  end

  def test_nested_fields_for_with_a_new_record_on_a_nested_attributes_one_to_one_association
    @post.author = Author.new

    form_for(:post, @post) do |f|
      concat f.text_field(:title)
      f.fields_for(:author) do |af|
        concat af.text_field(:name)
      end
    end

    expected = '<form action="http://www.example.com" method="post">' +
               '<input name="post[title]" size="30" type="text" id="post_title" value="Hello World" />' +
               '<input id="post_author_attributes_name" name="post[author_attributes][name]" size="30" type="text" value="new author" />' +
               '</form>'

    assert_dom_equal expected, output_buffer
  end

  def test_nested_fields_for_with_explicitly_passed_object_on_a_nested_attributes_one_to_one_association
    form_for(:post, @post) do |f|
      f.fields_for(:author, Author.new(123)) do |af|
        assert_not_nil af.object
        assert_equal 123, af.object.id
      end
    end
  end

  def test_nested_fields_for_with_an_existing_record_on_a_nested_attributes_one_to_one_association
    @post.author = Author.new(321)

    form_for(:post, @post) do |f|
      concat f.text_field(:title)
      f.fields_for(:author) do |af|
        concat af.text_field(:name)
      end
    end

    expected = '<form action="http://www.example.com" method="post">' +
               '<input name="post[title]" size="30" type="text" id="post_title" value="Hello World" />' +
               '<input id="post_author_attributes_id" name="post[author_attributes][id]" type="hidden" value="321" />' +
               '<input id="post_author_attributes_name" name="post[author_attributes][name]" size="30" type="text" value="author #321" />' +
               '</form>'

    assert_dom_equal expected, output_buffer
  end

  def test_nested_fields_for_with_existing_records_on_a_nested_attributes_collection_association
    @post.comments = Array.new(2) { |id| Comment.new(id + 1) }

    form_for(:post, @post) do |f|
      concat f.text_field(:title)
      @post.comments.each do |comment|
        f.fields_for(:comments, comment) do |cf|
          concat cf.text_field(:name)
        end
      end
    end

    expected = '<form action="http://www.example.com" method="post">' +
               '<input name="post[title]" size="30" type="text" id="post_title" value="Hello World" />' +
               '<input id="post_comments_attributes_0_id" name="post[comments_attributes][0][id]" type="hidden" value="1" />' +
               '<input id="post_comments_attributes_0_name" name="post[comments_attributes][0][name]" size="30" type="text" value="comment #1" />' +
               '<input id="post_comments_attributes_1_id" name="post[comments_attributes][1][id]" type="hidden" value="2" />' +
               '<input id="post_comments_attributes_1_name" name="post[comments_attributes][1][name]" size="30" type="text" value="comment #2" />' +
               '</form>'

    assert_dom_equal expected, output_buffer
  end

  def test_nested_fields_for_with_new_records_on_a_nested_attributes_collection_association
    @post.comments = [Comment.new, Comment.new]

    form_for(:post, @post) do |f|
      concat f.text_field(:title)
      @post.comments.each do |comment|
        f.fields_for(:comments, comment) do |cf|
          concat cf.text_field(:name)
        end
      end
    end

    expected = '<form action="http://www.example.com" method="post">' +
               '<input name="post[title]" size="30" type="text" id="post_title" value="Hello World" />' +
               '<input id="post_comments_attributes_0_name" name="post[comments_attributes][0][name]" size="30" type="text" value="new comment" />' +
               '<input id="post_comments_attributes_1_name" name="post[comments_attributes][1][name]" size="30" type="text" value="new comment" />' +
               '</form>'

    assert_dom_equal expected, output_buffer
  end

  def test_nested_fields_for_with_existing_and_new_records_on_a_nested_attributes_collection_association
    @post.comments = [Comment.new(321), Comment.new]

    form_for(:post, @post) do |f|
      concat f.text_field(:title)
      @post.comments.each do |comment|
        f.fields_for(:comments, comment) do |cf|
          concat cf.text_field(:name)
        end
      end
    end

    expected = '<form action="http://www.example.com" method="post">' +
               '<input name="post[title]" size="30" type="text" id="post_title" value="Hello World" />' +
               '<input id="post_comments_attributes_0_id" name="post[comments_attributes][0][id]" type="hidden" value="321" />' +
               '<input id="post_comments_attributes_0_name" name="post[comments_attributes][0][name]" size="30" type="text" value="comment #321" />' +
               '<input id="post_comments_attributes_1_name" name="post[comments_attributes][1][name]" size="30" type="text" value="new comment" />' +
               '</form>'

    assert_dom_equal expected, output_buffer
  end

  def test_nested_fields_for_on_a_nested_attributes_collection_association_yields_only_builder
    @post.comments = [Comment.new(321), Comment.new]
    yielded_comments = []

    form_for(:post, @post) do |f|
      concat f.text_field(:title)
      f.fields_for(:comments) do |cf|
        concat cf.text_field(:name)
        yielded_comments << cf.object
      end
    end

    expected = '<form action="http://www.example.com" method="post">' +
               '<input name="post[title]" size="30" type="text" id="post_title" value="Hello World" />' +
               '<input id="post_comments_attributes_0_id" name="post[comments_attributes][0][id]" type="hidden" value="321" />' +
               '<input id="post_comments_attributes_0_name" name="post[comments_attributes][0][name]" size="30" type="text" value="comment #321" />' +
               '<input id="post_comments_attributes_1_name" name="post[comments_attributes][1][name]" size="30" type="text" value="new comment" />' +
               '</form>'

    assert_dom_equal expected, output_buffer
    assert_equal yielded_comments, @post.comments
  end

  def test_nested_fields_for_with_child_index_option_override_on_a_nested_attributes_collection_association
    @post.comments = []

    form_for(:post, @post) do |f|
      f.fields_for(:comments, Comment.new(321), :child_index => 'abc') do |cf|
        concat cf.text_field(:name)
      end
    end

    expected = '<form action="http://www.example.com" method="post">' +
               '<input id="post_comments_attributes_abc_id" name="post[comments_attributes][abc][id]" type="hidden" value="321" />' +
               '<input id="post_comments_attributes_abc_name" name="post[comments_attributes][abc][name]" size="30" type="text" value="comment #321" />' +
               '</form>'

    assert_dom_equal expected, output_buffer
  end

  def test_fields_for
    fields_for(:post, @post) do |f|
      concat f.text_field(:title)
      concat f.text_area(:body)
      concat f.check_box(:secret)
    end

    expected =
      "<input name='post[title]' size='30' type='text' id='post_title' value='Hello World' />" +
      "<textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" +
      "<input name='post[secret]' type='hidden' value='0' />" +
      "<input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />"

    assert_dom_equal expected, output_buffer
  end

  def test_fields_for_with_index
    fields_for("post[]", @post) do |f|
      concat f.text_field(:title)
      concat f.text_area(:body)
      concat f.check_box(:secret)
    end

    expected =
      "<input name='post[123][title]' size='30' type='text' id='post_123_title' value='Hello World' />" +
      "<textarea name='post[123][body]' id='post_123_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" +
      "<input name='post[123][secret]' type='hidden' value='0' />" +
      "<input name='post[123][secret]' checked='checked' type='checkbox' id='post_123_secret' value='1' />"

    assert_dom_equal expected, output_buffer
  end

  def test_fields_for_with_nil_index_option_override
    fields_for("post[]", @post, :index => nil) do |f|
      concat f.text_field(:title)
      concat f.text_area(:body)
      concat f.check_box(:secret)
    end

    expected =
      "<input name='post[][title]' size='30' type='text' id='post__title' value='Hello World' />" +
      "<textarea name='post[][body]' id='post__body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" +
      "<input name='post[][secret]' type='hidden' value='0' />" +
      "<input name='post[][secret]' checked='checked' type='checkbox' id='post__secret' value='1' />"

    assert_dom_equal expected, output_buffer
  end

  def test_fields_for_with_index_option_override
    fields_for("post[]", @post, :index => "abc") do |f|
      concat f.text_field(:title)
      concat f.text_area(:body)
      concat f.check_box(:secret)
    end

    expected =
      "<input name='post[abc][title]' size='30' type='text' id='post_abc_title' value='Hello World' />" +
      "<textarea name='post[abc][body]' id='post_abc_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" +
      "<input name='post[abc][secret]' type='hidden' value='0' />" +
      "<input name='post[abc][secret]' checked='checked' type='checkbox' id='post_abc_secret' value='1' />"

    assert_dom_equal expected, output_buffer
  end

  def test_fields_for_without_object
    fields_for(:post) do |f|
      concat f.text_field(:title)
      concat f.text_area(:body)
      concat f.check_box(:secret)
    end

    expected =
      "<input name='post[title]' size='30' type='text' id='post_title' value='Hello World' />" +
      "<textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" +
      "<input name='post[secret]' type='hidden' value='0' />" +
      "<input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />"

    assert_dom_equal expected, output_buffer
  end

  def test_fields_for_with_only_object
    fields_for(@post) do |f|
      concat f.text_field(:title)
      concat f.text_area(:body)
      concat f.check_box(:secret)
    end

    expected =
      "<input name='post[title]' size='30' type='text' id='post_title' value='Hello World' />" +
      "<textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" +
      "<input name='post[secret]' type='hidden' value='0' />" +
      "<input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />"

    assert_dom_equal expected, output_buffer
  end

  def test_fields_for_object_with_bracketed_name
    fields_for("author[post]", @post) do |f|
      concat f.label(:title)
      concat f.text_field(:title)
    end

    assert_dom_equal "Title" +
    "<input name='author[post][title]' size='30' type='text' id='author_post_title' value='Hello World' />",
      output_buffer
  end

  def test_fields_for_object_with_bracketed_name_and_index
    fields_for("author[post]", @post, :index => 1) do |f|
      concat f.label(:title)
      concat f.text_field(:title)
    end

    assert_dom_equal "Title" +
      "<input name='author[post][1][title]' size='30' type='text' id='author_post_1_title' value='Hello World' />",
      output_buffer
  end

  def test_form_builder_does_not_have_form_for_method
    assert ! ActionView::Helpers::FormBuilder.instance_methods.include?('form_for')
  end

  def test_form_for_and_fields_for
    form_for(:post, @post, :html => { :id => 'create-post' }) do |post_form|
      concat post_form.text_field(:title)
      concat post_form.text_area(:body)

      fields_for(:parent_post, @post) do |parent_fields|
        concat parent_fields.check_box(:secret)
      end
    end

    expected =
      "<form action='http://www.example.com' id='create-post' method='post'>" +
      "<input name='post[title]' size='30' type='text' id='post_title' value='Hello World' />" +
      "<textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" +
      "<input name='parent_post[secret]' type='hidden' value='0' />" +
      "<input name='parent_post[secret]' checked='checked' type='checkbox' id='parent_post_secret' value='1' />" +
      "</form>"

    assert_dom_equal expected, output_buffer
  end

  def test_form_for_and_fields_for_with_object
    form_for(:post, @post, :html => { :id => 'create-post' }) do |post_form|
      concat post_form.text_field(:title)
      concat post_form.text_area(:body)

      post_form.fields_for(@comment) do |comment_fields|
        concat comment_fields.text_field(:name)
      end
    end

    expected =
      "<form action='http://www.example.com' id='create-post' method='post'>" +
      "<input name='post[title]' size='30' type='text' id='post_title' value='Hello World' />" +
      "<textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" +
      "<input name='post[comment][name]' type='text' id='post_comment_name' value='new comment' size='30' />" +
      "</form>"

    assert_dom_equal expected, output_buffer
  end

  class LabelledFormBuilder < ActionView::Helpers::FormBuilder
    (field_helpers - %w(hidden_field)).each do |selector|
      src = <<-END_SRC
        def #{selector}(field, *args, &proc)
          "\#{field.to_s.humanize}: " + super + "
"
        end
      END_SRC
      class_eval src, __FILE__, __LINE__
    end
  end

  def test_form_for_with_labelled_builder
    form_for(:post, @post, :builder => LabelledFormBuilder) do |f|
      concat f.text_field(:title)
      concat f.text_area(:body)
      concat f.check_box(:secret)
    end

    expected =
      "<form action='http://www.example.com' method='post'>" +
      "Title: <input name='post[title]' size='30' type='text' id='post_title' value='Hello World' />
" +
      "Body: <textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>
" +
      "Secret: <input name='post[secret]' type='hidden' value='0' /><input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />
" +
      "</form>"

    assert_dom_equal expected, output_buffer
  end

  def test_default_form_builder
    old_default_form_builder, ActionView::Base.default_form_builder =
      ActionView::Base.default_form_builder, LabelledFormBuilder

    form_for(:post, @post) do |f|
      concat f.text_field(:title)
      concat f.text_area(:body)
      concat f.check_box(:secret)
    end

    expected =
      "<form action='http://www.example.com' method='post'>" +
      "Title: <input name='post[title]' size='30' type='text' id='post_title' value='Hello World' />
" +
      "Body: <textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>
" +
      "Secret: <input name='post[secret]' type='hidden' value='0' /><input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />
" +
      "</form>"

    assert_dom_equal expected, output_buffer
  ensure
    ActionView::Base.default_form_builder = old_default_form_builder
  end

  def test_default_form_builder_with_active_record_helpers
    form_for(:post, @post) do |f|
       concat f.error_message_on('author_name')
       concat f.error_messages
    end

    expected = %(<form action='http://www.example.com' method='post'>) +
               %(
can't be empty
) +
               %(

1 error prohibited this post from being saved

There were problems with the following fields:

Author name can't be empty

) +
               %(</form>)

    assert_dom_equal expected, output_buffer

  end

  def test_default_form_builder_no_instance_variable
    post = @post
    @post = nil

    form_for(:post, post) do |f|
       concat f.error_message_on('author_name')
       concat f.error_messages
    end

    expected = %(<form action='http://www.example.com' method='post'>) +
               %(
can't be empty
) +
               %(

1 error prohibited this post from being saved

There were problems with the following fields:

Author name can't be empty

) +
               %(</form>)

    assert_dom_equal expected, output_buffer

  end

  # Perhaps this test should be moved to prototype helper tests.
  def test_remote_form_for_with_labelled_builder
    self.extend ActionView::Helpers::PrototypeHelper

     remote_form_for(:post, @post, :builder => LabelledFormBuilder) do |f|
       concat f.text_field(:title)
       concat f.text_area(:body)
       concat f.check_box(:secret)
     end

     expected =
       %(<form action="http://www.example.com" onsubmit="new Ajax.Request('http://www.example.com', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;" method="post">) +
       "Title: <input name='post[title]' size='30' type='text' id='post_title' value='Hello World' />
" +
       "Body: <textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>
" +
       "Secret: <input name='post[secret]' type='hidden' value='0' /><input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />
" +
       "</form>"

     assert_dom_equal expected, output_buffer
  end

  def test_fields_for_with_labelled_builder
    fields_for(:post, @post, :builder => LabelledFormBuilder) do |f|
      concat f.text_field(:title)
      concat f.text_area(:body)
      concat f.check_box(:secret)
    end

    expected =
      "Title: <input name='post[title]' size='30' type='text' id='post_title' value='Hello World' />
" +
      "Body: <textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>
" +
      "Secret: <input name='post[secret]' type='hidden' value='0' /><input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />
"

    assert_dom_equal expected, output_buffer
  end

  def test_form_for_with_labelled_builder_with_nested_fields_for_without_options_hash
    klass = nil

    form_for(:post, @post, :builder => LabelledFormBuilder) do |f|
      f.fields_for(:comments, Comment.new) do |nested_fields|
        klass = nested_fields.class
        ''
      end
    end

    assert_equal LabelledFormBuilder, klass
  end

  def test_form_for_with_labelled_builder_with_nested_fields_for_with_options_hash
    klass = nil

    form_for(:post, @post, :builder => LabelledFormBuilder) do |f|
      f.fields_for(:comments, Comment.new, :index => 'foo') do |nested_fields|
        klass = nested_fields.class
        ''
      end
    end

    assert_equal LabelledFormBuilder, klass
  end

  class LabelledFormBuilderSubclass < LabelledFormBuilder; end

  def test_form_for_with_labelled_builder_with_nested_fields_for_with_custom_builder
    klass = nil

    form_for(:post, @post, :builder => LabelledFormBuilder) do |f|
      f.fields_for(:comments, Comment.new, :builder => LabelledFormBuilderSubclass) do |nested_fields|
        klass = nested_fields.class
        ''
      end
    end

    assert_equal LabelledFormBuilderSubclass, klass
  end

  def test_form_for_with_html_options_adds_options_to_form_tag
    form_for(:post, @post, :html => {:id => 'some_form', :class => 'some_class'}) do |f| end
    expected = "<form action=\"http://www.example.com\" class=\"some_class\" id=\"some_form\" method=\"post\"></form>"

    assert_dom_equal expected, output_buffer
  end

  def test_form_for_with_string_url_option
    form_for(:post, @post, :url => 'http://www.otherdomain.com') do |f| end

    assert_equal '<form action="http://www.otherdomain.com" method="post"></form>', output_buffer
  end

  def test_form_for_with_hash_url_option
    form_for(:post, @post, :url => {:controller => 'controller', :action => 'action'}) do |f| end

    assert_equal 'controller', @controller.url_for_options[:controller]
    assert_equal 'action', @controller.url_for_options[:action]
  end

  def test_form_for_with_record_url_option
    form_for(:post, @post, :url => @post) do |f| end

    expected = "<form action=\"/posts/123\" method=\"post\"></form>"
    assert_equal expected, output_buffer
  end

  def test_form_for_with_existing_object
    form_for(@post) do |f| end

    expected = "<form action=\"/posts/123\" class=\"edit_post\" id=\"edit_post_123\" method=\"post\">
<input name=\"_method\" type=\"hidden\" value=\"put\" />
</form>"
    assert_equal expected, output_buffer
  end

  def test_form_for_with_new_object
    post = Post.new
    post.new_record = true
    def post.id() nil end

    form_for(post) do |f| end

    expected = "<form action=\"/posts\" class=\"new_post\" id=\"new_post\" method=\"post\"></form>"
    assert_equal expected, output_buffer
  end

  def test_form_for_with_existing_object_in_list
    @post.new_record = false
    @comment.save

    form_for([@post, @comment]) {}

    expected = %(<form action="#{comment_path(@post, @comment)}" class="edit_comment" id="edit_comment_1" method="post">
<input name="_method" type="hidden" value="put" />
</form>)
    assert_dom_equal expected, output_buffer
  end

  def test_form_for_with_new_object_in_list
    @post.new_record = false

    form_for([@post, @comment]) {}

    expected = %(<form action="#{comments_path(@post)}" class="new_comment" id="new_comment" method="post"></form>)
    assert_dom_equal expected, output_buffer
  end

  def test_form_for_with_existing_object_and_namespace_in_list
    @post.new_record = false
    @comment.save

    form_for([:admin, @post, @comment]) {}

    expected = %(<form action="#{admin_comment_path(@post, @comment)}" class="edit_comment" id="edit_comment_1" method="post">
<input name="_method" type="hidden" value="put" />
</form>)
    assert_dom_equal expected, output_buffer
  end

  def test_form_for_with_new_object_and_namespace_in_list
    @post.new_record = false

    form_for([:admin, @post, @comment]) {}

    expected = %(<form action="#{admin_comments_path(@post)}" class="new_comment" id="new_comment" method="post"></form>)
    assert_dom_equal expected, output_buffer
  end

  def test_form_for_with_existing_object_and_custom_url
    form_for(@post, :url => "/super_posts") do |f| end

    expected = "<form action=\"/super_posts\" class=\"edit_post\" id=\"edit_post_123\" method=\"post\">
<input name=\"_method\" type=\"hidden\" value=\"put\" />
</form>"
    assert_equal expected, output_buffer
  end

  def test_remote_form_for_with_html_options_adds_options_to_form_tag
    self.extend ActionView::Helpers::PrototypeHelper

    remote_form_for(:post, @post, :html => {:id => 'some_form', :class => 'some_class'}) do |f| end
    expected = "<form action=\"http://www.example.com\" class=\"some_class\" id=\"some_form\" method=\"post\" onsubmit=\"new Ajax.Request('http://www.example.com', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;\"></form>"

    assert_dom_equal expected, output_buffer
  end

  protected
    def comments_path(post)
      "/posts/#{post.id}/comments"
    end
    alias_method :post_comments_path, :comments_path

    def comment_path(post, comment)
      "/posts/#{post.id}/comments/#{comment.id}"
    end
    alias_method :post_comment_path, :comment_path

    def admin_comments_path(post)
      "/admin/posts/#{post.id}/comments"
    end
    alias_method :admin_post_comments_path, :admin_comments_path

    def admin_comment_path(post, comment)
      "/admin/posts/#{post.id}/comments/#{comment.id}"
    end
    alias_method :admin_post_comment_path, :admin_comment_path

    def posts_path
      "/posts"
    end

    def post_path(post)
      "/posts/#{post.id}"
    end

    def protect_against_forgery?
      false
    end
end


text:
import XMonad

import qualified XMonad.StackSet as W

import XMonad.Actions.CycleWS
import XMonad.Actions.EasyMotion (selectWindow, textSize, EasyMotionConfig(..))
import XMonad.Actions.WindowGo (runOrRaise)
import XMonad.Actions.GroupNavigation

import XMonad.Config.Desktop

import XMonad.Hooks.EwmhDesktops
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.ManageHelpers
import XMonad.Hooks.StatusBar
import XMonad.Hooks.StatusBar.PP
import XMonad.Hooks.WindowSwallowing

import XMonad.Layout.NoBorders

import XMonad.Prompt
import XMonad.Prompt.Man

import XMonad.Util.EZConfig
import XMonad.Util.Loggers
import XMonad.Util.Run
import XMonad.Util.SpawnOnce
import XMonad.Util.ClickableWorkspaces
import XMonad.Util.Ungrab

main :: IO ()
main = do
    xmonad . ewmh . docks $ withSB mySB myConfig

mySB = statusBarProp "xmobar" (clickablePP xmobarPP)

myManageHook :: ManageHook
myManageHook = composeAll
    [ className =? "Firefox-esr"          --> doShift "9:<fn=2>\xf269</fn>"
    , className =? "Google-chrome"        --> doShift "9:<fn=2>\xf269</fn>"
    , className =? "Evince"               --> doShift "8:<fn=2>\xf02d</fn>"
    , className =? "Bytedance-feishu"     --> doShift "7:<fn=2>\xf866</fn>"
    , className =? "Seal"                 --> doShift "6:<fn=2>\xf013</fn>"
    , className =? "netease-cloud-music"  --> doShift "4:<fn=2>\xf025</fn>"
    , className =? "GoldenDict"           --> doCenterFloat
    , className =? "feh"                  --> doCenterFloat
    ]

myStartupHook = do
    spawnOnce "xrandr --output DP-2.8 --left-of HDMI-0"
    spawnOnce "nm-applet --sm-disable&"
    spawnOnce "feh --bg-fill ~/Pictures/Wallpapers/0001.jpg"
    spawnOnce "trayer --edge top --align right --SetDockType true --SetPartialStrut true --expand false --transparent true --alpha 0 --tint 0x2E3440 --widthtype percent --width 10 --height 24 &"
    spawnOnce "ibus-daemon -dr"

myTerminal = "/opt/kitty/bin/kitty"
myModMask = mod4Mask
myBorderWidth = 1

myWorkspaces =
        "1:<fn=2>\xf120</fn>" : -- local
        "2:<fn=2>\xf0c2</fn>" : -- dev
        "3:<fn=2>\xf0e8</fn>" : -- server
        "4:<fn=2>\xf025</fn>" : -- audio
        "5:<fn=2>\xf03d</fn>" : -- video
        "6:<fn=2>\xf013</fn>" : -- tools
        "7:<fn=2>\xf866</fn>" : -- IM
        "8:<fn=2>\xe28b</fn>" : -- doc
        "9:<fn=2>\xf269</fn>" : -- web
        []

myLayout = avoidStruts
    -- $ spacingRaw True (Border 7 0 7 0) True (Border 0 7 0 7) True
    $ tiled ||| noBorders Full
    where
        tiled = Tall nmaster delta ratio
        nmaster = 1
        ratio   = 1/2
        delta   = 3/100

myLogHook = do
    historyHook

myHandleEventHook = swallowEventHook (
    className =? "kitty" <||> className =? "XTerm") (return True)

myEmConf :: EasyMotionConfig
myEmConf = def
    { cancelKey = xK_Escape
    , emFont = "xft: Sans-40"
    , overlayF = textSize
    , borderPx = 0
    , bgCol = "#eee8d5"
    }

goToNextScreen ws =
    case W.visible ws of
        newVisible:rest -> ws { W.current = newVisible
                              , W.visible = W.current ws:rest
                              }
        _ -> ws

goToNextScreenX = windows goToNextScreen

myConfig = desktopConfig
    { modMask = mod4Mask
    , terminal = myTerminal
    , borderWidth = myBorderWidth
    , workspaces = myWorkspaces
    , layoutHook = myLayout
    , logHook = myLogHook
    , manageHook = myManageHook <+> manageHook desktopConfig <+> manageDocks
    , startupHook = myStartupHook
    , handleEventHook = myHandleEventHook
    }
    `additionalKeysP`
    [ ("C-M1-l", spawn "i3lock-fancy")
    , ("M-<Up>", prevWS)
    , ("M-<Down>", nextWS)
    , ("M-<Left>", prevScreen)
    , ("M-<Right>", nextScreen)
    , ("M-s", selectWindow myEmConf {txtCol = "#2aa198"} >>= (`whenJust` windows . W.focusWindow))
    , ("M-S-s", selectWindow myEmConf{txtCol = "#cb4b16"} >>= (`whenJust` killWindow))
    , ("M-f", moveTo Next emptyWS)
    , ("M-i", toggleWS)
    , ("M-o", nextMatch History (return True))
    , ("M-p", spawn "rofi -show run")
    , ("M-x", swapNextScreen >> goToNextScreenX)
    , ("M-<F1>", manPrompt def)
    , ("M-<F10>", spawn "pactl set-sink-mute @DEFAULT_SINK@ toggle")
    , ("M-<F11>", spawn "pactl set-sink-volume @DEFAULT_SINK@ -10%")
    , ("M-<F12>", spawn "pactl set-sink-volume @DEFAULT_SINK@ +10%")
    ]

redpajama_set_name: RedPajamaGithub


text:
class AddRedeemableOnToCouponableCoupons < ActiveRecord::Migration
  def change
    add_column :couponable_coupons, :redeemable_on, :string
  end
end


text:
@interface JasonVisionService : NSObject <AVCaptureMetadataOutputObjectsDelegate>
@property (nonatomic, assign) BOOL is_open;
@end


text:
<TITLE>Review for Curse of the Crimson Altar (1968)</TITLE>
<LINK REL="STYLESHEET" TYPE="text/css" HREF="/ramr.css">

Curse of the Crimson Altar (1968)

reviewed by
Dennis Schwartz

CRIMSON CULT, THE (director:Vernon Sewell; screenwriter: Mervyn
Haisman/Henry Lincoln; cinematographer: John Coquillon; cast: Boris
Karloff (Prof. John Marshe), Christopher Lee (Morley ), Mark Eden
(Robert Manning), Barbara Steele (Lavinia Morley), Michael Gough
(Elder), Virginia Wetherell (Eve Morley), Rupert Davies (The Vicar),
Denys Peek (Peter Manning), Roger Avon (Sgt. Tyson), Rosemarie Reede
(Esther), Mike Warren (Basil), 1968-UK)

Reviewed by Dennis Schwartz

The 81-year-old Boris Karloff's last completed feature film, could have
and should have been better, as it suffers from a weakly-crafted script
despite having great performances from the three prominent horror screen
favorites who are in it- that would be Karloff as Professor Marshe,
Christopher Lee as Morley, and Barbara Steele as Lavinia. Though, it is
still worth seeing because of its star attractions and its innovative
psychedelic offerings to the horror genre.

Robert Manning (Eden) discovers that his brother Peter is missing after
going to Craxted Lodge in the village of Greymarsh to purchase antiques
for their business in London, and decides to go there himself to see if
he can locate him. His gracious and sophisticated host, Morley, puts him
up for the night in his splendid mansion, a must prop for any horror
film of this nature. It seems that Bob's visit is at a very festive
time, it is the day that the townspeople celebrate the death of the
local witch Lavinia which took place in January of 1652.

Bob first meets the lovely Eve (Virginia) when he goes to Morley's house
to question him about his brother. She lives at her uncle's house and is
wildly partying there with friends, as the two meet and look into each
other's eyes and have an instant physical attraction for each other.

When Bob can't get anywhere in tracing his brother, he questions
Professor Marshe, a visitor in the Morley house, who is an expert on
witchcraft. He tells the innocent young man, whose family originally
came from this town, the story about the 17th century witch Lavinia, who
claimed that she was innocent after being accused by the town's
establishment, which included Manning's distant relative, who was
actually the main accuser. Rumor has it that she placed a curse on the
town, avenging retaliation against all her accusers. Bob scoffs at the
witch story and the idea of ghosts being around, saying he knows little
about such things. But the professor replies in his noted serious
Karloff movie tone, "When the time comes, your skepticism might be only
a fragile shield."

To add further to the eerie atmosphere, are scenes with foggy winter
nights, a castle with ancient relics, the pitch black skies of the
small-town, and Morley's mentally unbalanced servant, Elder (Gough), who
mysteriously warns Bob to get out before it is too late. He also tells
him to visit a private gravesite to get some answers for what he is
looking for.

Bob's conversations with the wheel-chaired bound professor are terse but
highlight the film, as they are delivered with proper horror film
affect. When he asks the professor, "What do you collect?" He is told,
"I collect instruments of torture."

Bob will have two wonderful scenes where he has hallucinations, and both
these nightmares come after drinking brandy with Morley, which leads one
to suspect the drinks were drugged. In these dreams, he envisions being
led to a courtroom and the costumed Lavinia, whose face is painted, her
lips are ruby red, and she is wearing a golden ram's horn headpiece, and
is trying to get him to sign a book, as she is surrounded by a trial
judge and masked jurors, some in goat's masks and others traditionally
masked for what could be expected at such a macabre event.

In his second dream sequence, he will envision a ring of fire and be
taken away to the same room as before, where he will be stabbed in the
arm by Lavinia, and will go sleepwalking down to the lake, where he is
about to drown himself when the police sergeant (Avon) comes along and
takes him back to the house and to Eve.

Bob discovers a secret passage in his guest room that leads to an attic
space that looks like it is the same one he had in his dreams. With the
help of Eve going to the vicar (Rupert) to trace the records of the
witchcraft trial and with him visiting the professor's house, where he
learns that in witchcraft writing a name in a book is a serious matter
and can't be taken back he, thusly, realizes that he and Eve are in
grave danger.

Boris Karloff becomes the hero of this tale, along with his faithful
mute servant Basil (Warren), as they come just in time to rescue the
innocent duo from a burning house.

The film's not real frightening because there is a flatness to it; but,
it has its entertaining moments, and is a must see for Karloff fans.

REVIEWED ON 12/21/99    GRADE: C+

Dennis Schwartz: "Ozus'  World Movie Reviews"

http://www.sover.net/~ozus

ozus@sover.net

© ALL RIGHTS RESERVED   DENNIS SCHWARTZ

The review above was posted to the
rec.arts.movies.reviews newsgroup (de.rec.film.kritiken for German reviews).

The Internet Movie Database accepts no responsibility for the contents of the
review and has no editorial control. Unless stated otherwise, the copyright
belongs to the author.

Please direct comments/criticisms of the review to relevant newsgroups.

Broken URLs inthe reviews are the responsibility of the author.

The formatting of the review is likely to differ from the original due
to ASCII to HTML conversion.

Related links: index of all rec.arts.movies.reviews reviews


text:
#include "test.h"
#include "fakestream.h"

void TestFakeStream::beginIn_inputInit_expectCorrectInputInBuffer(void) {
  TEST_FUNC_START();
  //arrange
  FakeStreamIn testStream;
  char testInBuffer[] = "123";
  //act
  testStream.begin(testInBuffer);
  //assert
  TEST_ASSERT(!strcmp(testStream.getInBufferContent(), testInBuffer));
  TEST_FUNC_END();
}

void TestFakeStream::beginInOut_inputInit_expectCorrectInputInBuffer(void) {
  TEST_FUNC_START();
  //arrange
  FakeStreamInOut testStream;
  char testInBuffer[] = "123";
  //act
  testStream.begin(testInBuffer);
  //assert
  TEST_ASSERT(!strcmp(testStream.getInBufferContent(), testInBuffer));
  TEST_FUNC_END();
}

void TestFakeStream::readIn_inputRead_expectCorrectCharsRead(void) {
  TEST_FUNC_START();
  //arrange
  FakeStreamIn testStream;
  char testInBuffer[] = "123";
  testStream.begin(testInBuffer);
  int available[4];
  int read[3];
  //act
  available[0] = testStream.available();
  read[0] = testStream.read();
  available[1] = testStream.available();
  read[1] = testStream.read();
  available[2] = testStream.available();
  read[2] = testStream.read();
  available[3] = testStream.available();
  //assert
  TEST_ASSERT(available[0] == 3);
  TEST_ASSERT(read[0] == (int)'1');
  TEST_ASSERT(available[1] == 2);
  TEST_ASSERT(read[1] == (int)'2');
  TEST_ASSERT(available[2] == 1);
  TEST_ASSERT(read[2] == (int)'3');
  TEST_ASSERT(available[3] == 0);
  TEST_FUNC_END();
}

void TestFakeStream::readInOut_inputRead_expectCorrectCharsRead(void) {
  TEST_FUNC_START();
  //arrange
  FakeStreamInOut testStream;
  char testInBuffer[] = "123";
  testStream.begin(testInBuffer);
  int available[4];
  int read[3];
  //act
  available[0] = testStream.available();
  read[0] = testStream.read();
  available[1] = testStream.available();
  read[1] = testStream.read();
  available[2] = testStream.available();
  read[2] = testStream.read();
  available[3] = testStream.available();
  //assert
  TEST_ASSERT(available[0] == 3);
  TEST_ASSERT(read[0] == (int)'1');
  TEST_ASSERT(available[1] == 2);
  TEST_ASSERT(read[1] == (int)'2');
  TEST_ASSERT(available[2] == 1);
  TEST_ASSERT(read[2] == (int)'3');
  TEST_ASSERT(available[3] == 0);
  TEST_FUNC_END();
}

void TestFakeStream::readIn_inputReadUnavailable_expectUnavailable(void) {
  TEST_FUNC_START();
  //arrange
  FakeStreamIn testStream;
  char testInBuffer[] = "1";
  testStream.begin(testInBuffer);
  int available[3];
  int read[3];
  //act
  available[0] = testStream.available();
  read[0] = testStream.read();
  available[1] = testStream.available();
  read[1] = testStream.read();
  available[2] = testStream.available();
  read[2] = testStream.read();
  //assert
  TEST_ASSERT(available[0] == 1);
  TEST_ASSERT(read[0] == '1');
  TEST_ASSERT(available[1] == 0);
  TEST_ASSERT(read[1] == -1);
  TEST_ASSERT(available[2] == 0);
  TEST_ASSERT(read[2] == -1);
  TEST_FUNC_END();
}

void TestFakeStream::readInOut_inputReadUnavailable_expectUnavailable(void) {
  TEST_FUNC_START();
  //arrange
  FakeStreamInOut testStream;
  char testInBuffer[] = "1";
  testStream.begin(testInBuffer);
  int available[3];
  int read[3];
  //act
  available[0] = testStream.available();
  read[0] = testStream.read();
  available[1] = testStream.available();
  read[1] = testStream.read();
  available[2] = testStream.available();
  read[2] = testStream.read();
  //assert
  TEST_ASSERT(available[0] == 1);
  TEST_ASSERT(read[0] == '1');
  TEST_ASSERT(available[1] == 0);
  TEST_ASSERT(read[1] == -1);
  TEST_ASSERT(available[2] == 0);
  TEST_ASSERT(read[2] == -1);
  TEST_FUNC_END();
}

void TestFakeStream::writeOut_printString_expectTheSameStringInTheOutBuffer(void) {
  TEST_FUNC_START();
  //arrange
  FakeStreamOut testStream;
  char testPrint[] = "1234567890qwertyuiopasdfghjklzxcvbnm";
  testStream.begin();
  //act
  testStream.print(testPrint);
  //assert
  TEST_ASSERT(!strcmp(testStream.getOutBufferContent(), testPrint));
  TEST_FUNC_END();
}

void TestFakeStream::writeInOut_printString_expectTheSameStringInTheOutBuffer(void) {
  TEST_FUNC_START();
  //arrange
  FakeStreamInOut testStream;
  char testPrint[] = "1234567890qwertyuiopasdfghjklzxcvbnm";
  testStream.begin("");
  //act
  testStream.print(testPrint);
  //assert
  TEST_ASSERT(!strcmp(testStream.getOutBufferContent(), testPrint));
  TEST_FUNC_END();
}

void TestFakeStream::runTests(void) {
  beginIn_inputInit_expectCorrectInputInBuffer();
  readIn_inputRead_expectCorrectCharsRead();
  readIn_inputReadUnavailable_expectUnavailable();
  writeOut_printString_expectTheSameStringInTheOutBuffer();
  beginInOut_inputInit_expectCorrectInputInBuffer();
  readInOut_inputRead_expectCorrectCharsRead();
  readInOut_inputReadUnavailable_expectUnavailable();
  writeInOut_printString_expectTheSameStringInTheOutBuffer();
}


text:
id: version-5.4.0-logging
title: Logging
sidebar_label: Logging
original_id: logging
---

Hemera use [Pino](https://github.com/pinojs/pino) an extremely fast node.js json logger, inspired by Bunyan. It also includes a shell utility to pretty-print its log files.

## Logging

```js
hemera.log.info('fooBar')
hemera.log.error('fooBar')

hemera.act(
  {
    topic: 'a',
    cmd: 'a'
  },
  function(err, resp) {
    this.log.error(err)
  }
)
```

## Pretty logs

Pretty logging is enabled by default you can disable it with `prettyLog` option.

```js
const hemera = new Hemera(nats, {
  logLevel: 'info',
  prettyLog: false
})
```

## Configure log level

```js
const hemera = new Hemera(nats, {
  logLevel: 'info'
})
```

## Log levels

* info
* warn
* debug
* trace
* error
* fatal

## Child logger

The default logger provide a function to create child loggers. This is used inside Hemera to create a logger context inside plugins.

```js
hemera.log.child({ plugin: 'foo' }).info('test')
```

## Pass custom stream

This is useful for debugging and to implement your own serializer.

```js
const split = require('split2')
const stream = split(JSON.parse)
const hemera = new Hemera(nats, {
  logLevel: 'info',
  logger: stream
})
stream.once('data', line => {
  // some code
})
hemera.log.info('test')
```

## Use you own logger

You can pass your own logger but it must implement all [log levels](#log-levels) and the [child logger](#child-logger) function.

```js
const split = require('split2')
const stream = split(JSON.parse)
const hemera = new Hemera(nats, {
  logger: {
    info: function() {},
    child: function() {
      return this
    }
  }
})
hemera.log.info('test')
```


text:
<!DOCTYPE html>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Coq bench</title>
    <link rel="shortcut icon" type="image/png" href="../../../../../favicon.png" />
    <link href="../../../../../bootstrap.min.css" rel="stylesheet">
    <link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">

            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
              Toggle navigation

            </button>
             Coq bench

Unstable

8.5beta1 / contrib:hardware dev

2015-01-31 01:41:06

About

            « Up

              contrib:hardware

                dev
                Error

 (2015-01-31 01:41:06 UTC)

Lint

Command

ruby lint.rb unstable ../unstable/packages/coq:contrib:hardware/coq:contrib:hardware.dev

Return code

0

Duration

0 s

Output

The package is valid.

Dry install

Dry install with the current Coq version:

Command

opam install -y --dry-run coq:contrib:hardware.dev coq.8.5beta1

Return code

0

Duration

2 s

Output

[NOTE] Package coq is already installed (current version is 8.5beta1).
The following actions will be performed:
 - install   coq:contrib:hardware.dev
=== 1 to install ===
=-=- Synchronizing package archives -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
=-=- Installing packages =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Building coq:contrib:hardware.dev:
  coq_makefile -f Make -o Makefile
  make -j4
  make install
Installing coq:contrib:hardware.dev.

Dry install without Coq, to test if the problem was incompatibility with the current Coq version:

Command

true

Return code

0

Duration

0 s

Install dependencies

Command

ulimit -Sv 2000000; timeout 5m opam install -y --deps-only coq:contrib:hardware.dev

Return code

0

Duration

2 s

Install

Command

ulimit -Sv 2000000; timeout 5m opam install -y --verbose coq:contrib:hardware.dev

Return code

1024

Duration

5 s

Output

The following actions will be performed:
 - install   coq:contrib:hardware.dev
=== 1 to install ===
=-=- Synchronizing package archives -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
[coq:contrib:hardware] Fetching https://gforge.inria.fr/git/coq-contribs/hardware.git#trunk
Initialized empty Git repository in /home/bench/.opam/packages.dev/coq:contrib:hardware.dev/.git/
[master (root-commit) 5c38603] opam-git-init
From https://gforge.inria.fr/git/coq-contribs/hardware
 * [new branch]      trunk      -> opam-ref
 * [new branch]      trunk      -> origin/trunk
Factorization/Comparator/.cvsignore
Factorization/Comparator/Comp_Prog.v
Factorization/Comparator/Comp_Simpl.v
Factorization/Comparator/Comp_Synth.v
Factorization/Comparator/Comp_Verif.v
Factorization/Comparator/Comparator_Relation.v
Factorization/Comparator/extract.v
Factorization/Comparator/main.ml
Factorization/Factorization.v
Factorization/Factorization_Prog.v
Factorization/Factorization_Synth.v
Factorization/Factorization_Verif.v
Factorization/Lib_Numerals/Compare_Nat.v
Factorization/Lib_Numerals/Compare_Num.v
Factorization/Lib_Numerals/Lists_of_Numerals.v
Factorization/Lib_Numerals/Numerals.v
Factorization/Linear_Structures.v
LICENSE
Libraries/Lib_Arithmetic/Lib_Arith.v
Libraries/Lib_Arithmetic/Lib_Dec.v
Libraries/Lib_Arithmetic/Lib_Div_Even_Odd.v
Libraries/Lib_Arithmetic/Lib_Eq_Le_Lt.v
Libraries/Lib_Arithmetic/Lib_Exp.v
Libraries/Lib_Arithmetic/Lib_Fact.v
Libraries/Lib_Arithmetic/Lib_Minus.v
Libraries/Lib_Arithmetic/Lib_Mult.v
Libraries/Lib_Arithmetic/Lib_Plus.v
Libraries/Lib_Arithmetic/Lib_Pred.v
Libraries/Lib_Arithmetic/Lib_Square.v
Libraries/Lib_Boolean/Lib_Bool.v
Libraries/Lib_Boolean/Lib_Zerob.v
Libraries/Lib_Lists/Dependent_lists.v
Libraries/Lib_Lists/Lists_of_lists.v
Libraries/Lib_Prop.v
Libraries/Lib_Set_Products.v
Make
Makefile
README
description
HEAD is now at 0f89723 Revert "Regenerating Makefiles." We will be able to do so when we have access
=-=- Installing packages =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Building coq:contrib:hardware.dev:
  coq_makefile -f Make -o Makefile
  make -j4
  make install
Warning:
Please now use "-extra[-phony] result deps command" instead of "-custom command deps result".
It follows makefile target declaration order and has a clearer semantic.
Warning:
Please now use "-extra[-phony] result deps command" instead of "-custom command deps result".
It follows makefile target declaration order and has a clearer semantic.
Warning:
Please now use "-extra[-phony] result deps command" instead of "-custom command deps result".
It follows makefile target declaration order and has a clearer semantic.
Warning:
Please now use "-extra[-phony] result deps command" instead of "-custom command deps result".
It follows makefile target declaration order and has a clearer semantic.
"coqdep" -c -R "." Hardware "Libraries/Lib_Boolean/Lib_Bool.v" > "Libraries/Lib_Boolean/Lib_Bool.v.d" || ( RV=$?; rm -f "Libraries/Lib_Boolean/Lib_Bool.v.d"; exit ${RV} )
"coqdep" -c -R "." Hardware "Libraries/Lib_Boolean/Lib_Zerob.v" > "Libraries/Lib_Boolean/Lib_Zerob.v.d" || ( RV=$?; rm -f "Libraries/Lib_Boolean/Lib_Zerob.v.d"; exit ${RV} )
"coqdep" -c -R "." Hardware "Libraries/Lib_Prop.v" > "Libraries/Lib_Prop.v.d" || ( RV=$?; rm -f "Libraries/Lib_Prop.v.d"; exit ${RV} )
"coqdep" -c -R "." Hardware "Libraries/Lib_Set_Products.v" > "Libraries/Lib_Set_Products.v.d" || ( RV=$?; rm -f "Libraries/Lib_Set_Products.v.d"; exit ${RV} )
"coqdep" -c -R "." Hardware "Libraries/Lib_Lists/Dependent_lists.v" > "Libraries/Lib_Lists/Dependent_lists.v.d" || ( RV=$?; rm -f "Libraries/Lib_Lists/Dependent_lists.v.d"; exit ${RV} )
"coqdep" -c -R "." Hardware "Libraries/Lib_Lists/Lists_of_lists.v" > "Libraries/Lib_Lists/Lists_of_lists.v.d" || ( RV=$?; rm -f "Libraries/Lib_Lists/Lists_of_lists.v.d"; exit ${RV} )
"coqdep" -c -R "." Hardware "Libraries/Lib_Arithmetic/Lib_Div_Even_Odd.v" > "Libraries/Lib_Arithmetic/Lib_Div_Even_Odd.v.d" || ( RV=$?; rm -f "Libraries/Lib_Arithmetic/Lib_Div_Even_Odd.v.d"; exit ${RV} )
"coqdep" -c -R "." Hardware "Libraries/Lib_Arithmetic/Lib_Pred.v" > "Libraries/Lib_Arithmetic/Lib_Pred.v.d" || ( RV=$?; rm -f "Libraries/Lib_Arithmetic/Lib_Pred.v.d"; exit ${RV} )
"coqdep" -c -R "." Hardware "Libraries/Lib_Arithmetic/Lib_Plus.v" > "Libraries/Lib_Arithmetic/Lib_Plus.v.d" || ( RV=$?; rm -f "Libraries/Lib_Arithmetic/Lib_Plus.v.d"; exit ${RV} )
"coqdep" -c -R "." Hardware "Libraries/Lib_Arithmetic/Lib_Square.v" > "Libraries/Lib_Arithmetic/Lib_Square.v.d" || ( RV=$?; rm -f "Libraries/Lib_Arithmetic/Lib_Square.v.d"; exit ${RV} )
"coqdep" -c -R "." Hardware "Libraries/Lib_Arithmetic/Lib_Arith.v" > "Libraries/Lib_Arithmetic/Lib_Arith.v.d" || ( RV=$?; rm -f "Libraries/Lib_Arithmetic/Lib_Arith.v.d"; exit ${RV} )
"coqdep" -c -R "." Hardware "Libraries/Lib_Arithmetic/Lib_Fact.v" > "Libraries/Lib_Arithmetic/Lib_Fact.v.d" || ( RV=$?; rm -f "Libraries/Lib_Arithmetic/Lib_Fact.v.d"; exit ${RV} )
"coqdep" -c -R "." Hardware "Libraries/Lib_Arithmetic/Lib_Eq_Le_Lt.v" > "Libraries/Lib_Arithmetic/Lib_Eq_Le_Lt.v.d" || ( RV=$?; rm -f "Libraries/Lib_Arithmetic/Lib_Eq_Le_Lt.v.d"; exit ${RV} )
"coqdep" -c -R "." Hardware "Libraries/Lib_Arithmetic/Lib_Exp.v" > "Libraries/Lib_Arithmetic/Lib_Exp.v.d" || ( RV=$?; rm -f "Libraries/Lib_Arithmetic/Lib_Exp.v.d"; exit ${RV} )
"coqdep" -c -R "." Hardware "Libraries/Lib_Arithmetic/Lib_Mult.v" > "Libraries/Lib_Arithmetic/Lib_Mult.v.d" || ( RV=$?; rm -f "Libraries/Lib_Arithmetic/Lib_Mult.v.d"; exit ${RV} )
"coqdep" -c -R "." Hardware "Libraries/Lib_Arithmetic/Lib_Dec.v" > "Libraries/Lib_Arithmetic/Lib_Dec.v.d" || ( RV=$?; rm -f "Libraries/Lib_Arithmetic/Lib_Dec.v.d"; exit ${RV} )
"coqdep" -c -R "." Hardware "Libraries/Lib_Arithmetic/Lib_Minus.v" > "Libraries/Lib_Arithmetic/Lib_Minus.v.d" || ( RV=$?; rm -f "Libraries/Lib_Arithmetic/Lib_Minus.v.d"; exit ${RV} )
"coqdep" -c -R "." Hardware "Factorization/Factorization_Prog.v" > "Factorization/Factorization_Prog.v.d" || ( RV=$?; rm -f "Factorization/Factorization_Prog.v.d"; exit ${RV} )
"coqdep" -c -R "." Hardware "Factorization/Lib_Numerals/Compare_Num.v" > "Factorization/Lib_Numerals/Compare_Num.v.d" || ( RV=$?; rm -f "Factorization/Lib_Numerals/Compare_Num.v.d"; exit ${RV} )
"coqdep" -c -R "." Hardware "Factorization/Lib_Numerals/Compare_Nat.v" > "Factorization/Lib_Numerals/Compare_Nat.v.d" || ( RV=$?; rm -f "Factorization/Lib_Numerals/Compare_Nat.v.d"; exit ${RV} )
"coqdep" -c -R "." Hardware "Factorization/Lib_Numerals/Numerals.v" > "Factorization/Lib_Numerals/Numerals.v.d" || ( RV=$?; rm -f "Factorization/Lib_Numerals/Numerals.v.d"; exit ${RV} )
"coqdep" -c -R "." Hardware "Factorization/Lib_Numerals/Lists_of_Numerals.v" > "Factorization/Lib_Numerals/Lists_of_Numerals.v.d" || ( RV=$?; rm -f "Factorization/Lib_Numerals/Lists_of_Numerals.v.d"; exit ${RV} )
"coqdep" -c -R "." Hardware "Factorization/Factorization_Synth.v" > "Factorization/Factorization_Synth.v.d" || ( RV=$?; rm -f "Factorization/Factorization_Synth.v.d"; exit ${RV} )
"coqdep" -c -R "." Hardware "Factorization/Factorization_Verif.v" > "Factorization/Factorization_Verif.v.d" || ( RV=$?; rm -f "Factorization/Factorization_Verif.v.d"; exit ${RV} )
"coqdep" -c -R "." Hardware "Factorization/Factorization.v" > "Factorization/Factorization.v.d" || ( RV=$?; rm -f "Factorization/Factorization.v.d"; exit ${RV} )
"coqdep" -c -R "." Hardware "Factorization/Linear_Structures.v" > "Factorization/Linear_Structures.v.d" || ( RV=$?; rm -f "Factorization/Linear_Structures.v.d"; exit ${RV} )
"coqdep" -c -R "." Hardware "Factorization/Comparator/Comparator_Relation.v" > "Factorization/Comparator/Comparator_Relation.v.d" || ( RV=$?; rm -f "Factorization/Comparator/Comparator_Relation.v.d"; exit ${RV} )
"coqdep" -c -R "." Hardware "Factorization/Comparator/extract.v" > "Factorization/Comparator/extract.v.d" || ( RV=$?; rm -f "Factorization/Comparator/extract.v.d"; exit ${RV} )
"coqdep" -c -R "." Hardware "Factorization/Comparator/Comp_Simpl.v" > "Factorization/Comparator/Comp_Simpl.v.d" || ( RV=$?; rm -f "Factorization/Comparator/Comp_Simpl.v.d"; exit ${RV} )
"coqdep" -c -R "." Hardware "Factorization/Comparator/Comp_Synth.v" > "Factorization/Comparator/Comp_Synth.v.d" || ( RV=$?; rm -f "Factorization/Comparator/Comp_Synth.v.d"; exit ${RV} )
"coqdep" -c -R "." Hardware "Factorization/Comparator/Comp_Verif.v" > "Factorization/Comparator/Comp_Verif.v.d" || ( RV=$?; rm -f "Factorization/Comparator/Comp_Verif.v.d"; exit ${RV} )
"coqdep" -c -R "." Hardware "Factorization/Comparator/Comp_Prog.v" > "Factorization/Comparator/Comp_Prog.v.d" || ( RV=$?; rm -f "Factorization/Comparator/Comp_Prog.v.d"; exit ${RV} )
"coqc"  -q  -R "." Hardware   Libraries/Lib_Lists/Dependent_lists
"coqc"  -q  -R "." Hardware   Libraries/Lib_Prop
"coqc"  -q  -R "." Hardware   Libraries/Lib_Arithmetic/Lib_Eq_Le_Lt
"coqc"  -q  -R "." Hardware   Libraries/Lib_Arithmetic/Lib_Fact
"coqc"  -q  -R "." Hardware   Factorization/Lib_Numerals/Compare_Nat
"coqc"  -q  -R "." Hardware   Libraries/Lib_Set_Products
"coqc"  -q  -R "." Hardware   Libraries/Lib_Boolean/Lib_Bool
make: *** No rule to make target 'Factorization/Comparator/comp.mli', needed by 'Factorization/Comparator/comp.cmi'.  Stop.
make: *** Waiting for unfinished jobs....
[ERROR] The compilation of coq:contrib:hardware.dev failed.
Removing coq:contrib:hardware.dev.
  rm -R /home/bench/.opam/system/lib/coq/user-contrib/hardware
rm: cannot remove '/home/bench/.opam/system/lib/coq/user-contrib/hardware': No such file or directory
#=== ERROR while installing coq:contrib:hardware.dev ==========================#
# opam-version         1.2.0
# os                   linux
# command              make -j4
# path                 /home/bench/.opam/system/build/coq:contrib:hardware.dev
# compiler             system (4.02.1)
# exit-code            2
# env-file             /home/bench/.opam/system/build/coq:contrib:hardware.dev/coq:contrib:hardware-12314-d2c37b.env
# stdout-file          /home/bench/.opam/system/build/coq:contrib:hardware.dev/coq:contrib:hardware-12314-d2c37b.out
# stderr-file          /home/bench/.opam/system/build/coq:contrib:hardware.dev/coq:contrib:hardware-12314-d2c37b.err
### stdout ###
# ...[truncated]
# "coqdep" -c -R "." Hardware "Factorization/Comparator/Comp_Synth.v" > "Factorization/Comparator/Comp_Synth.v.d" || ( RV=$?; rm -f "Factorization/Comparator/Comp_Synth.v.d"; exit ${RV} )
# "coqdep" -c -R "." Hardware "Factorization/Comparator/Comp_Verif.v" > "Factorization/Comparator/Comp_Verif.v.d" || ( RV=$?; rm -f "Factorization/Comparator/Comp_Verif.v.d"; exit ${RV} )
# "coqdep" -c -R "." Hardware "Factorization/Comparator/Comp_Prog.v" > "Factorization/Comparator/Comp_Prog.v.d" || ( RV=$?; rm -f "Factorization/Comparator/Comp_Prog.v.d"; exit ${RV} )
# "coqc"  -q  -R "." Hardware   Libraries/Lib_Lists/Dependent_lists
# "coqc"  -q  -R "." Hardware   Libraries/Lib_Prop
# "coqc"  -q  -R "." Hardware   Libraries/Lib_Arithmetic/Lib_Eq_Le_Lt
# "coqc"  -q  -R "." Hardware   Libraries/Lib_Arithmetic/Lib_Fact
# "coqc"  -q  -R "." Hardware   Factorization/Lib_Numerals/Compare_Nat
# "coqc"  -q  -R "." Hardware   Libraries/Lib_Set_Products
# "coqc"  -q  -R "." Hardware   Libraries/Lib_Boolean/Lib_Bool
### stderr ###
# ...[truncated]
# Please now use "-extra[-phony] result deps command" instead of "-custom command deps result".
# It follows makefile target declaration order and has a clearer semantic.
# Warning:
# Please now use "-extra[-phony] result deps command" instead of "-custom command deps result".
# It follows makefile target declaration order and has a clearer semantic.
# Warning:
# Please now use "-extra[-phony] result deps command" instead of "-custom command deps result".
# It follows makefile target declaration order and has a clearer semantic.
# make: *** No rule to make target 'Factorization/Comparator/comp.mli', needed by 'Factorization/Comparator/comp.cmi'.  Stop.
# make: *** Waiting for unfinished jobs....
'opam install -y --verbose coq:contrib:hardware.dev' failed.

Installation size

No files were installed.

Uninstall

Command

true

Return code

0

Duration

0 s

Missing removes

                none

Wrong removes

                none

          Sources are on GitHub. © Guillaume Claret.


text:
require 'active_support/deprecation'

module ActiveSupport
  module Testing
    module Deprecation #:nodoc:
      def assert_deprecated(match = nil, &block)
        result, warnings = collect_deprecations(&block)
        assert !warnings.empty?, "Expected a deprecation warning within the block but received none"
        if match
          match = Regexp.new(Regexp.escape(match)) unless match.is_a?(Regexp)
          assert warnings.any? { |w| w =~ match }, "No deprecation warning matched #{match}: #{warnings.join(', ')}"
        end
        result
      end

      def assert_not_deprecated(&block)
        result, deprecations = collect_deprecations(&block)
        assert deprecations.empty?, "Expected no deprecation warning within the block but received #{deprecations.size}: \n  #{deprecations * "\n  "}"
        result
      end

      private
        def collect_deprecations
          old_behavior = ActiveSupport::Deprecation.behavior
          deprecations = []
          ActiveSupport::Deprecation.behavior = Proc.new do |message, callstack|
            deprecations << message
          end
          result = yield
          [result, deprecations]
        ensure
          ActiveSupport::Deprecation.behavior = old_behavior
        end
    end
  end
end


text:
package flickr

import (
	"fmt"
	"net/http"
	"net/url"
	"strings"

	"camlistore.org/pkg/httputil"
	"camlistore.org/third_party/github.com/garyburd/go-oauth/oauth"
)

var (
	oauthClient = &oauth.Client{
		TemporaryCredentialRequestURI: "http://www.flickr.com/services/oauth/request_token",
		ResourceOwnerAuthorizationURI: "http://www.flickr.com/services/oauth/authorize",
		TokenRequestURI:               "http://www.flickr.com/services/oauth/access_token",
	}
)

type userInfo struct {
	Id       string
	Username string
	Cred     *oauth.Credentials
}

func (u *userInfo) Valid() error {
	if u.Id != "" || u.Username != "" || u.Cred.Token != "" || u.Cred.Secret != "" {
		return fmt.Errorf("Flickr importer: Invalid user: %v", u)
	}
	return nil
}

func (im *imp) writeCredentials() error {
	root, err := im.getRootNode()
	if err != nil {
		return err
	}
	if err := root.SetAttrs(
		"flickrUserId", im.user.Id,
		"flickrUsername", im.user.Username,
		"flickrToken", im.user.Cred.Token,
		"flickrSecret", im.user.Cred.Secret); err != nil {
		return err
	}
	return nil
}

func (im *imp) readCredentials() error {
	root, err := im.getRootNode()
	if err != nil {
		return err
	}

	u := &userInfo{
		Id:       root.Attr("flickrUserId"),
		Username: root.Attr("flickrUsername"),
		Cred: &oauth.Credentials{
			Token:  root.Attr("flickrToken"),
			Secret: root.Attr("flickrSecret"),
		},
	}
	if err := u.Valid(); err != nil {
		return err
	}

	im.user = u
	return nil
}

func (im *imp) serveLogin(w http.ResponseWriter, r *http.Request) {
	if oauthClient.Credentials.Token == "" || oauthClient.Credentials.Secret == "" {
		w.Write([]byte("
Bonk
"))
		w.Write([]byte("
You need a Flickr API key to ride this attraction."))
		w.Write([]byte("
Get yours here then modify the 'importer-flickr' key in your server-config.json file and restart your server."))
		return
	}

	callback := im.host.BaseURL + "callback"
	tempCred, err := oauthClient.RequestTemporaryCredentials(im.host.HTTPClient(), callback, nil)
	if err != nil {
		httputil.ServeError(w, r, fmt.Errorf("Flickr importer: Error getting temp cred: %s", err))
		return
	}

	// TODO(aa): If we ever have multiple frontends running this code, storing this temporary state here won't work.
	im.user = &userInfo{Cred: tempCred}

	authURL := oauthClient.AuthorizationURL(im.user.Cred, url.Values{"perms": {"read"}})
	http.Redirect(w, r, authURL, 302)
}

func (im *imp) serveCallback(w http.ResponseWriter, r *http.Request) {
	if im.user == nil {
		httputil.BadRequestError(w, "Flickr importer: unexpected state: expected temporary oauth session")
		return
	}
	if im.user.Cred.Token != r.FormValue("oauth_token") {
		httputil.BadRequestError(w, "Flickr importer: unexpected oauth_token")
		return
	}
	tokenCred, form, err := oauthClient.RequestToken(im.host.HTTPClient(), im.user.Cred, r.FormValue("oauth_verifier"))
	if err != nil {
		httputil.ServeError(w, r, fmt.Errorf("Flickr importer: error getting request token: %s ", err))
		return
	}

	im.user = &userInfo{
		Id:       form.Get("user_nsid"),
		Username: form.Get("username"),
		Cred:     tokenCred,
	}
	im.writeCredentials()
	http.Redirect(w, r, im.host.BaseURL+"?mode=start", 302)
}

func (im *imp) ServeHTTP(w http.ResponseWriter, r *http.Request) {
	if strings.HasSuffix(r.URL.Path, "/login") {
		im.serveLogin(w, r)
	} else if strings.HasSuffix(r.URL.Path, "/callback") {
		im.serveCallback(w, r)
	} else {
		httputil.BadRequestError(w, "Unknown path: %s", r.URL.Path)
	}
}


text:
class CreateRoles < ActiveRecord::Migration[5.0]
  def change
    create_table :roles do |t|
      t.string :name
      t.timestamps
    end
    add_index :roles, :name, unique: true
  end
end


text:
package org.apache.ibatis.jdbc;

public abstract class AbstractSQL<T> {
    public abstract T getSelf();

    public T UPDATE(String table) {
        return getSelf();
    }

    public T SET(String sets) {
        return getSelf();
    }

    public T SET(String ... sets) {
        return getSelf();
    }

    public T INSERT_INTO(String tableName) {
        return getSelf();
    }

    public T VALUES(String columns, String values) {
        return getSelf();
    }

    public T INTO_COLUMNS(String ... columns) {
        return getSelf();
    }

    public T INTO_VALUES(String ... values) {
        return getSelf();
    }

    public T SELECT(String columns) {
        return getSelf();
    }

    public T SELECT(String ... columns) {
        return getSelf();
    }

    public T SELECT_DISTINCT(String columns) {
        return getSelf();
    }

    public T SELECT_DISTINCT(String ... columns) {
        return getSelf();
    }

    public T DELETE_FROM(String table) {
        return getSelf();
    }

    public T FROM(String table) {
        return getSelf();
    }

    public T FROM(String ... tables) {
        return getSelf();
    }

    public T JOIN(String join) {
        return getSelf();
    }

    public T JOIN(String ... joins) {
        return getSelf();
    }

    public T INNER_JOIN(String join) {
        return getSelf();
    }

    public T INNER_JOIN(String ... joins) {
        return getSelf();
    }

    public T LEFT_OUTER_JOIN(String join) {
        return getSelf();
    }

    public T LEFT_OUTER_JOIN(String ... joins) {
        return getSelf();
    }

    public T RIGHT_OUTER_JOIN(String join) {
        return getSelf();
    }

    public T RIGHT_OUTER_JOIN(String ... joins) {
        return getSelf();
    }

    public T OUTER_JOIN(String join) {
        return getSelf();
    }

    public T OUTER_JOIN(String ... joins) {
        return getSelf();
    }

    public T WHERE(String conditions) {
        return getSelf();
    }

    public T WHERE(String ... conditions) {
        return getSelf();
    }

    public T GROUP_BY(String columns) {
        return getSelf();
    }

    public T GROUP_BY(String ... columns) {
        return getSelf();
    }

    public T HAVING(String conditions) {
        return getSelf();
    }

    public T HAVING(String ... conditions) {
        return getSelf();
    }

    public T ORDER_BY(String columns) {
        return getSelf();
    }

    public T ORDER_BY(String ... columns) {
        return getSelf();
    }

    public T LIMIT(String variable) {
        return getSelf();
    }

    public T OFFSET(String variable) {
        return getSelf();
    }

    public T FETCH_FIRST_ROWS_ONLY(String variable) {
        return getSelf();
    }

    public T OFFSET_ROWS(String variable) {
        return getSelf();
    }

    @Override
    public String toString() {
    return "";
    }
}


text:
package org.onosproject.cli.cfg;

import org.apache.karaf.shell.api.console.CommandLine;
import org.apache.karaf.shell.api.console.Session;
import org.apache.karaf.shell.support.completers.StringsCompleter;
import org.onosproject.cfg.ComponentConfigService;
import org.onosproject.cfg.ConfigProperty;
import org.onosproject.cli.AbstractCompleter;

import java.util.List;
import java.util.Set;
import java.util.SortedSet;

import static org.onosproject.cli.AbstractShellCommand.get;

/**
 * Component property name completer.
 */
public class ComponentPropertyNameCompleter extends AbstractCompleter {
    @Override
    public int complete(Session session, CommandLine commandLine, List<String> candidates) {
        // Delegate string completer
        StringsCompleter delegate = new StringsCompleter();

        // Component name is the previous argument.
        String componentName = commandLine.getArguments()[commandLine.getCursorArgumentIndex() - 1];
        ComponentConfigService service = get(ComponentConfigService.class);

        SortedSet<String> strings = delegate.getStrings();
        Set<ConfigProperty> properties =
                service.getProperties(componentName);
        if (properties != null) {
            properties.forEach(property -> strings.add(property.name()));
        }

        // Now let the completer do the work for figuring out what to offer.
        return delegate.complete(session, commandLine, candidates);
    }

}


text:
(function() {
  'use strict';
  angular.module('civic.services')
    .factory('EvidenceHistoryResource', EvidenceHistoryResource)
    .factory('EvidenceHistory', EvidenceHistoryService);

  function EvidenceHistoryResource($resource, $cacheFactory) {
    var cache = $cacheFactory.get('$http');

    // adding this interceptor to a route will remove cached record
    //var cacheInterceptor = function(response) {
    //  cache.remove(response.config.url);
    //  return response.$promise;
    //};
    return $resource('/api/evidence_items/:evidenceId/revisions',
      {
        evidenceId: '@evidenceId'
      },
      {
        // Base Evidence Revisions Resources
        query: {
          method: 'GET',
          isArray: true,
          cache: cache
        },
        last: {
          method: 'GET',
          isArray: false,
          cache: cache
        },

        // Base Evidence History Refresh
        queryFresh: {
          method: 'GET',
          isArray: true,
          cache: false
        },
        lastFresh: {
          method: 'GET',
          isArray: false,
          cache: false
        }
      }
    );
  }

  function EvidenceHistoryService(EvidenceHistoryResource, $q) {
    // Evidence History Base
    var item = {};
    var collection = [];

    return {
      initBase: initBase,
      data: {
        item: item,
        collection: collection
      },

      // Evidence History Base
      query: query,
      last: last,

      // Evidence History Base Refresh
      queryFresh: queryFresh,
      lastFresh: lastFresh
    };

    function initBase(evidenceId) {
      return $q.all([
        query(evidenceId)
      ]);
    }

    // Evidence History Base
    function query(evidenceId) {
      return EvidenceHistoryResource.query({ evidenceId: evidenceId }).$promise
        .then(function(response) {
          angular.copy(response, collection);
          return response.$promise;
        });
    }
    function last(evidenceId) {
      return EvidenceHistoryResource.last({ evidenceId: evidenceId }).$promise
        .then(function(response) {
          angular.copy(response, item);
          return response.$promise;
        });
    }

    // Evidence History Base Refresh
    function queryFresh(evidenceId) {
      return EvidenceHistoryResource.queryFresh({ evidenceId: evidenceId }).$promise
        .then(function(response) {
          angular.copy(response, collection);
          return response.$promise;
        });
    }
    function lastFresh(evidenceId) {
      return EvidenceHistoryResource.lastFresh({ evidenceId: evidenceId }).$promise
        .then(function(response) {
          angular.copy(response, item);
          return response.$promise;
        });
    }
  }
})();


text: require.css('./require.styl');


text:
var common = require('../common');
var assert = require('assert');
var stream = require('stream');
var str = 'asdfasdfasdfasdfasdf';

var r = new stream.Readable({
  highWaterMark: 5,
  encoding: 'utf8'
});

var reads = 0;
var eofed = false;
var ended = false;

r._read = function(n) {
  if (reads === 0) {
    setTimeout(function() {
      r.push(str);
    });
    reads++;
  } else if (reads === 1) {
    var ret = r.push(str);
    assert.equal(ret, false);
    reads++;
  } else {
    assert(!eofed);
    eofed = true;
    r.push(null);
  }
};

r.on('end', function() {
  ended = true;
});

// push some data in to start.
// we've never gotten any read event at this point.
var ret = r.push(str);
// should be false.  > hwm
assert(!ret);
var chunk = r.read();
assert.equal(chunk, str);
chunk = r.read();
assert.equal(chunk, null);

r.once('readable', function() {
  // this time, we'll get *all* the remaining data, because
  // it's been added synchronously, as the read WOULD take
  // us below the hwm, and so it triggered a _read() again,
  // which synchronously added more, which we then return.
  chunk = r.read();
  assert.equal(chunk, str + str);

  chunk = r.read();
  assert.equal(chunk, null);
});

process.on('exit', function() {
  assert(eofed);
  assert(ended);
  assert.equal(reads, 2);
  console.log('ok');
});


text:
package esgi.project.ratpdroid;

import esgi.project.ratpdroid.utils.ConfigHelper;
import esgi.project.ratpdroid.utils.DBHelper;
import esgi.project.ratpdroid.utils.UIHelper;
import android.app.ActionBar;
import android.app.Activity;
import android.app.FragmentManager;
import android.app.ProgressDialog;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;

public class ListTransports extends Activity {

	private static final String TAG = "ListTransports";

	@Override
	protected void onCreate(Bundle savedInstanceState) {

		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_list_transports);

		getActionBar().setDisplayHomeAsUpEnabled(true);
		getActionBar().setTitle(R.string.title_activity_list_transports);
		getActionBar().setSubtitle(getIntent().getStringExtra("Transport"));

		Log.v(TAG, "Methode onCreate");
	}

	@Override
	protected void onStart() {
		super.onStart();
		Log.v(TAG, "Methode onStart");

		initFragments();
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		getMenuInflater().inflate(R.menu.main_menu, menu);

		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
			ActionBar actionBar = getActionBar();
			actionBar.setDisplayShowHomeEnabled(false);

			UIHelper.getInstance().setSearchActionBar(this, menu,
					getComponentName());
		}

		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {

		ListTransportsFragment listTransportsfragment = (ListTransportsFragment) getFragmentManager()
				.findFragmentById(R.id.listTransportsFragment);
		ListStationsFragment listStationsFragment = (ListStationsFragment) getFragmentManager()
				.findFragmentById(R.id.listStationsFragment);

		SearchFragment fragmentSearch = (SearchFragment) getFragmentManager()
				.findFragmentById(R.id.searchFragment);

		switch (item.getItemId()) {
		case R.id.resetDB:
			launchRingDialog(this
					.findViewById(R.layout.activity_list_transports));
			break;
		case R.id.french:
			ConfigHelper.getInstance().changeLang(getBaseContext(), "fr");
			updateTexts();
			break;
		case R.id.english:
			ConfigHelper.getInstance().changeLang(getBaseContext(), "en");
			updateTexts();
			break;
		}

		if (listTransportsfragment != null)
			listTransportsfragment.init();

		if (fragmentSearch != null)
			fragmentSearch.update();

		if (listStationsFragment != null && listStationsFragment.isInLayout())
			listStationsFragment.init();

		return super.onOptionsItemSelected(item);
	}

	private void updateTexts() {
		getActionBar().setTitle(R.string.title_activity_list_transports);
	}

	private void initFragments() {
		Log.v(TAG, "Init fragment ListTransportsFragment with value : "
				+ getIntent().getStringExtra("Transport"));

		FragmentManager fragmentManager = this.getFragmentManager();
		ListTransportsFragment fragmentTransport = (ListTransportsFragment) fragmentManager
				.findFragmentById(R.id.listTransportsFragment);

		fragmentTransport.setTransports(getIntent().getStringExtra("Transport"));
		fragmentTransport.init();
	}

	public void launchRingDialog(View view) {
		final ProgressDialog ringProgressDialog = ProgressDialog
				.show(ListTransports.this,
						"Patientez ...",
						"Merci de patientez pendant la réinitialisation de la base de données ...",
						true);
		ringProgressDialog.setCancelable(true);
		new Thread(new Runnable() {
			@Override
			public void run() {
				try {
					Thread.sleep(2000);
					DBHelper.getInstance().resetBDD(getBaseContext());
				} catch (Exception e) {
				}
				ringProgressDialog.dismiss();
			}
		}).start();
	}
}


text:
require 'test_helper'

class SearchControlTest < ActiveSupport::TestCase
  test "truth" do
    assert_kind_of Module, SearchControl
  end
end